Open vio opened 3 years ago
+1
Any news on how can we use relative-ci
in a monorepo with multiple packages?
Hi @gjsduarte! Sorry, I forgot to update the issue, this is currently in progress and will be available for beta testing soon.
Looking forward to test that 😊
Once you have an existing organization/project:
Let me know if you encounter any issues or if you need assistance setting up the CI.
The list will show all the repositories with RelativeCI GitHub app installations no matter if they correspond to a RelativeCI project.
The CI configuration is the same as for a single project, except that you need to add and pass secrets for each project in case you run the build process for multiple projects on the same CI workflow:
PROJECT_1_RELATIVE_CI_KEY=***
PROJECT_2_RELATIVE_CI_KEY=***
Depending on your configuration method, you will need to pass corresponding keys to each task:
// .github/workflows/build.yaml
....
- name: Build project 1
run: npm run build --if-present
env:
RELATIVE_CI_KEY: ${{ secrets.PROJECT_1_RELATIVE_CI_KEY }}
...
- name: Build project 2
run: npm run build --if-present
env:
RELATIVE_CI_KEY: ${{ secrets.PROJECT_2_RELATIVE_CI_KEY }}
Example repository: https://github.com/relative-ci/example-webpack-plugin-github-action-monorepo
If we are not using github actions, how can we pass separate relativeci.config.js locations?
Looking at https://relative-ci.com/documentation/setup/agent/cli/#step-3-configure-relative-ciagent
We need to pass different paths to the stats json file for each app. The only way I have been able to get this to work is to run npx relative-ci-agent
in the directory where the config file is located for each app.
Is there a flag/value we can pass to the relative-ci-agent to use specific config files? Or is the only way to use config files to run the agent from the relative directive?
Hi @neilsoult, thanks for reaching out!
The only way I have been able to get this to work is to run npx relative-ci-agent in the directory where the config file is located for each app.
Yes, atm @relative-ci/agent
cli must run on the config's directory.
The agent uses cosmiconfig and only searches for the config file in the current directory or up the tree. Also, loading the webpack stats JSON file is done relative to the current working directory and fails when the value is relative to relativeci.config.js (like in the example). I will add an example for the CLI monorepo setup.
On a monorepo setup, are you expecting to be able to run from the root directory npx relative-ci-agent --config app-1/relativeci.config.js
? Do you find the method more convenient than cd app-1 && npx relative-ci-agent
?
On a monorepo setup, are you expecting to be able to run from the root directory
npx relative-ci-agent --config app-1/relativeci.config.js
? Do you find the method more convenient thancd app-1 && npx relative-ci-agent
?
yes, that would be ideal - we use Nx, and our build commands are run from the root directory of the monorepo - so while we could do something like cd app-1 && npx relative-ci-agent
, it would be more convenient to pass in a config flag with url
I think that's a valid case. I created a new issue on the agent: https://github.com/relative-ci/agent/issues/670. We will look to implement a --config-dir
argument to support all file formats that cosmiconfig supports.
Thanks for reporting it!
@neilsoult custom config directory is now available on @relative-ci/agent@4.1.0-beta.0
npx relative-ci-agent --config-dir packages/components
# or
npx relative-ci-agent -c packages/components
Let me know how it goes if you get the chance to try it ;)
Allow to setup multiple RelativeCI projects on one repository