relative-ci / roadmap

Issues, questions and feature requests for RelativeCI
https://relative-ci.com
3 stars 0 forks source link

Support for monorepos #30

Open vio opened 3 years ago

vio commented 3 years ago

Allow to setup multiple RelativeCI projects on one repository

promontis commented 3 years ago

+1

gjsduarte commented 2 years ago

Any news on how can we use relative-ci in a monorepo with multiple packages?

vio commented 2 years ago

Hi @gjsduarte! Sorry, I forgot to update the issue, this is currently in progress and will be available for beta testing soon.

gjsduarte commented 2 years ago

Looking forward to test that 😊

vio commented 2 years ago

🚀 Monorepo support is now in public beta

Once you have an existing organization/project:

  1. Follow the setup steps
  2. Check CI configuration differences

Let me know if you encounter any issues or if you need assistance setting up the CI.


Setup steps:

Step 1. Navigate to the organization page and click 'Add project'

1-organization-view

Step 2. Click on "Check available GitHub installations"

2-add-project

Step 3. Select the repository

The list will show all the repositories with RelativeCI GitHub app installations no matter if they correspond to a RelativeCI project.

3-select-repo

Step 4. Enter project details

4-project-details

CI configuration

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

neilsoult commented 2 years ago

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?

vio commented 2 years ago

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 ?

neilsoult commented 2 years ago

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 ?

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

vio commented 2 years ago

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!

vio commented 2 years ago

@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 ;)