Skip to content

Commit

Permalink
chore: decouple setup dev container from preparing projects (SMR-18) (#…
Browse files Browse the repository at this point in the history
…3019)

Co-authored-by: hallieswan <[email protected]>
  • Loading branch information
tschaffter and hallieswan authored Feb 25, 2025
1 parent 606fc52 commit 519c811
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 4 deletions.
16 changes: 15 additions & 1 deletion .github/actions/setup-dev-container/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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 \
Expand Down
12 changes: 9 additions & 3 deletions .github/workflows/e2e-agora.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/sonar-scan-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/sonar-scan-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down

0 comments on commit 519c811

Please sign in to comment.