Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for monorepos #30

Open
vio opened this issue Jun 16, 2021 · 10 comments
Open

Support for monorepos #30

vio opened this issue Jun 16, 2021 · 10 comments
Assignees
Labels
cloud Issue related to app.relative-ci.com hosted service

Comments

@vio
Copy link
Member

vio commented Jun 16, 2021

Allow to setup multiple RelativeCI projects on one repository

@promontis
Copy link

+1

@gjsduarte
Copy link

gjsduarte commented Oct 29, 2021

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

@vio vio self-assigned this Nov 1, 2021
@vio
Copy link
Member Author

vio commented Nov 1, 2021

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

@gjsduarte
Copy link

Looking forward to test that 😊

@vio
Copy link
Member Author

vio commented Nov 9, 2021

🚀 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
Copy link

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
Copy link
Member Author

vio commented Aug 18, 2022

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
Copy link

neilsoult commented Aug 18, 2022

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
Copy link
Member Author

vio commented Aug 18, 2022

I think that's a valid case. I created a new issue on the agent: relative-ci/agent#670. We will look to implement a --config-dir argument to support all file formats that cosmiconfig supports.

Thanks for reporting it!

@vio
Copy link
Member Author

vio commented Aug 25, 2022

@neilsoult custom config directory is now available on @relative-ci/[email protected]

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

@vio vio added cloud Issue related to app.relative-ci.com hosted service enterprise and removed enterprise labels Jan 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cloud Issue related to app.relative-ci.com hosted service
Projects
None yet
Development

No branches or pull requests

4 participants