diff --git a/.github/actions/setup-dev-container/action.yml b/.github/actions/setup-dev-container/action.yml index 5663ac30e..b20514fcb 100644 --- a/.github/actions/setup-dev-container/action.yml +++ b/.github/actions/setup-dev-container/action.yml @@ -5,6 +5,10 @@ inputs: description: 'The dev container user.' required: false default: 'ubuntu' +outputs: + affected_projects: + description: 'The list of affected Nx projects as a comma separated string.' + value: ${{ steps.get-affected-projects.outputs.affected_projects }} runs: using: 'composite' steps: @@ -78,4 +82,14 @@ runs: /home/${DEVCONTAINER_USER}/.local \ /home/${DEVCONTAINER_USER}/.gradle \ && . ./dev-env.sh \ - && workspace-install-affected" + && workspace-install-nodejs-dependencies" + + - name: Get affected Nx projects + id: get-affected-projects + shell: bash + run: | + AFFECTED_PROJECTS=$(devcontainer exec --workspace-folder ../sage-monorepo bash -c " + . ./dev-env.sh && nx show projects --affected --sep ','") + echo "Affected projects: $AFFECTED_PROJECTS" + echo "affected_projects=$AFFECTED_PROJECTS" >> $GITHUB_ENV + echo "affected_projects=$AFFECTED_PROJECTS" >> $GITHUB_OUTPUT diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8aef9a41c..60ac3c53f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,6 +37,11 @@ jobs: - name: Set up the dev container uses: ./.github/actions/setup-dev-container + - name: Prepare the affected projects + run: | + devcontainer exec --workspace-folder ../sage-monorepo bash -c ". ./dev-env.sh \ + && workspace-install-affected" + - name: Lint the affected projects run: | devcontainer exec --workspace-folder ../sage-monorepo bash -c ". ./dev-env.sh \ @@ -103,6 +108,11 @@ jobs: - name: Set up the dev container uses: ./.github/actions/setup-dev-container + - name: Prepare the affected projects + run: | + devcontainer exec --workspace-folder ../sage-monorepo bash -c ". ./dev-env.sh \ + && workspace-install-affected" + - name: Lint the affected projects run: | devcontainer exec --workspace-folder ../sage-monorepo bash -c ". ./dev-env.sh \ diff --git a/.github/workflows/e2e-agora.yaml b/.github/workflows/e2e-agora.yaml index 0bc306a0a..bbff7427e 100644 --- a/.github/workflows/e2e-agora.yaml +++ b/.github/workflows/e2e-agora.yaml @@ -38,14 +38,20 @@ jobs: uses: nrwl/nx-set-shas@v4 - name: Set up the dev container + id: setup-dev-container uses: ./.github/actions/setup-dev-container - name: Check if Agora was affected id: agora_affected run: | - AFFECTED=$(devcontainer exec --workspace-folder ../sage-monorepo bash -c ". ./dev-env.sh \ - && nx show projects --affected | grep -q 'agora' && echo 'true' || echo 'false'") - echo "AFFECTED=${AFFECTED}" >> "${GITHUB_OUTPUT}" + IFS=',' read -ra PROJECTS <<< "${{ steps.setup-dev-container.outputs.affected_projects }}" + for project in "${PROJECTS[@]}"; do + if [[ "$project" == agora-* ]]; then + echo "AFFECTED=true" >> "${GITHUB_OUTPUT}" + exit 0 + fi + done + echo "AFFECTED=false" >> "${GITHUB_OUTPUT}" - name: Install Playwright Browsers if: steps.agora_affected.outputs.AFFECTED == 'true' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5e234cc88..57a77e429 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -39,6 +39,14 @@ jobs: - name: Set up the dev container uses: ./.github/actions/setup-dev-container + # TODO: Identify the projects that actually need to be prepared. Here I'm not expecting any + # affected project since this workflow does not affect projects. For now I'm keeping the + # same behavior as before this change. + - name: Prepare the affected projects + run: | + devcontainer exec --workspace-folder ../sage-monorepo bash -c ". ./dev-env.sh \ + && workspace-install-affected" + - name: Build the Docker images for the specified product run: | devcontainer exec --workspace-folder ../sage-monorepo bash -c ". ./dev-env.sh \ diff --git a/.github/workflows/sonar-scan-pull-request.yml b/.github/workflows/sonar-scan-pull-request.yml index 340a9057b..d6d7f15e6 100644 --- a/.github/workflows/sonar-scan-pull-request.yml +++ b/.github/workflows/sonar-scan-pull-request.yml @@ -34,6 +34,11 @@ jobs: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} uses: ./.github/actions/setup-dev-container + - name: Prepare the affected projects + run: | + devcontainer exec --workspace-folder ../sage-monorepo bash -c ". ./dev-env.sh \ + && workspace-install-affected" + - name: Scan the affected projects with Sonar run: | devcontainer exec --workspace-folder ../sage-monorepo bash -c ". ./dev-env.sh \ diff --git a/.github/workflows/sonar-scan-push.yml b/.github/workflows/sonar-scan-push.yml index 441454b89..a0c825384 100644 --- a/.github/workflows/sonar-scan-push.yml +++ b/.github/workflows/sonar-scan-push.yml @@ -28,6 +28,11 @@ jobs: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} uses: ./.github/actions/setup-dev-container + - name: Prepare the affected projects + run: | + devcontainer exec --workspace-folder ../sage-monorepo bash -c ". ./dev-env.sh \ + && workspace-install-affected" + - name: Scan the affected projects with Sonar run: | devcontainer exec --workspace-folder ../sage-monorepo bash -c ". ./dev-env.sh \