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

ci(sage-monorepo): create a GH composite action to setup the dev container #2438

Merged
merged 5 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions .github/actions/setup-dev-container/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: 'Set up the dev container'
description: 'Installs the dev container CLI, fetches caches (if exist), and starts the dev container'
runs:
using: 'composite'
steps:
- name: Set up Yarn cache
uses: actions/cache@v3
with:
path: '/tmp/.yarn/cache'
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-

- name: Set up Renv cache
uses: actions/cache@v3
with:
path: '/tmp/.cache/R/renv/cache'
key: ${{ runner.os }}-renv-cache-${{ hashFiles('**/renv.lock') }}
restore-keys: |
${{ runner.os }}-renv-cache-

- name: Set up Poetry cache
uses: actions/cache@v3
with:
path: '/tmp/.cache/pypoetry'
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}

- name: Set up venv cache
uses: actions/cache@v3
with:
path: |
/tmp/.local/share/virtualenv
**/.venv
key: ${{ runner.os }}-venv-${{ hashFiles('**/poetry.lock') }}

- name: Set up Gradle cache
uses: actions/cache@v3
with:
path: |
/tmp/.gradle/caches
/tmp/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-

- name: Install the Dev Container CLI
shell: bash
run: npm install -g @devcontainers/[email protected]

- name: Start the dev container
shell: bash
run: |
mkdir -p \
/tmp/.yarn/cache \
/tmp/.cache/R/renv/cache \
/tmp/.cache/pypoetry \
/tmp/.local/share/virtualenv \
/tmp/.gradle/caches \
/tmp/.gradle/wrapper

devcontainer up \
--mount type=bind,source=/tmp/.yarn/cache,target=/workspaces/sage-monorepo/.yarn/cache \
--mount type=bind,source=/tmp/.cache/R/renv/cache,target=/home/vscode/.cache/R/renv/cache \
--mount type=bind,source=/tmp/.cache/pypoetry,target=/home/vscode/.cache/pypoetry \
--mount type=bind,source=/tmp/.local/share/virtualenv,target=/home/vscode/.local/share/virtualenv \
--mount type=bind,source=/tmp/.gradle/caches,target=/home/vscode/.gradle/caches \
--mount type=bind,source=/tmp/.gradle/wrapper,target=/home/vscode/.gradle/wrapper \
--workspace-folder ../sage-monorepo

- name: Prepare the workspace
shell: bash
run: |
devcontainer exec --workspace-folder ../sage-monorepo bash -c "
sudo chown -R vscode:vscode \
/workspaces/sage-monorepo \
/home/vscode/.cache \
/home/vscode/.local \
/home/vscode/.gradle \
&& . ./dev-env.sh \
&& workspace-install-affected"
146 changes: 2 additions & 144 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,78 +31,7 @@ jobs:
- name: Derive appropriate SHAs for base and head for `nx affected` commands
uses: nrwl/nx-set-shas@v3

- name: Set up Yarn cache
uses: actions/cache@v3
with:
path: '/tmp/.yarn/cache'
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-

- name: Set up Renv cache
uses: actions/cache@v3
with:
path: '/tmp/.cache/R/renv/cache'
key: ${{ runner.os }}-renv-cache-${{ hashFiles('**/renv.lock') }}
restore-keys: |
${{ runner.os }}-renv-cache-

- name: Set up Poetry cache
uses: actions/cache@v3
with:
path: '/tmp/.cache/pypoetry'
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}

- name: Set up venv cache
uses: actions/cache@v3
with:
path: |
/tmp/.local/share/virtualenv
**/.venv
key: ${{ runner.os }}-venv-${{ hashFiles('**/poetry.lock') }}

- name: Set up Gradle cache
uses: actions/cache@v3
with:
path: |
/tmp/.gradle/caches
/tmp/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-

- name: Install the Dev Container CLI
run: npm install -g @devcontainers/[email protected]

- name: Start the dev container
run: |
mkdir -p \
/tmp/.yarn/cache \
/tmp/.cache/R/renv/cache \
/tmp/.cache/pypoetry \
/tmp/.local/share/virtualenv \
/tmp/.gradle/caches \
/tmp/.gradle/wrapper

devcontainer up \
--mount type=bind,source=/tmp/.yarn/cache,target=/workspaces/sage-monorepo/.yarn/cache \
--mount type=bind,source=/tmp/.cache/R/renv/cache,target=/home/vscode/.cache/R/renv/cache \
--mount type=bind,source=/tmp/.cache/pypoetry,target=/home/vscode/.cache/pypoetry \
--mount type=bind,source=/tmp/.local/share/virtualenv,target=/home/vscode/.local/share/virtualenv \
--mount type=bind,source=/tmp/.gradle/caches,target=/home/vscode/.gradle/caches \
--mount type=bind,source=/tmp/.gradle/wrapper,target=/home/vscode/.gradle/wrapper \
--workspace-folder ../sage-monorepo

- name: Prepare the workspace
run: |
devcontainer exec --workspace-folder ../sage-monorepo bash -c "
sudo chown -R vscode:vscode \
/workspaces/sage-monorepo \
/home/vscode/.cache \
/home/vscode/.local \
/home/vscode/.gradle \
&& . ./dev-env.sh \
&& workspace-install-affected"
- uses: ./.github/actions/setup-dev-container

- name: Lint the affected projects
run: |
Expand Down Expand Up @@ -161,78 +90,7 @@ jobs:
- name: Derive appropriate SHAs for base and head for `nx affected` commands
uses: nrwl/nx-set-shas@v3

- name: Set up Yarn cache
uses: actions/cache@v3
with:
path: '/tmp/.yarn/cache'
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-

- name: Set up Renv cache
uses: actions/cache@v3
with:
path: '/tmp/.cache/R/renv/cache'
key: ${{ runner.os }}-renv-cache-${{ hashFiles('**/renv.lock') }}
restore-keys: |
${{ runner.os }}-renv-cache-

- name: Set up Poetry cache
uses: actions/cache@v3
with:
path: '/tmp/.cache/pypoetry'
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}

- name: Set up venv cache
uses: actions/cache@v3
with:
path: |
/tmp/.local/share/virtualenv
**/.venv
key: ${{ runner.os }}-venv-${{ hashFiles('**/poetry.lock') }}

- name: Set up Gradle cache
uses: actions/cache@v3
with:
path: |
/tmp/.gradle/caches
/tmp/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-

- name: Install the Dev Container CLI
run: npm install -g @devcontainers/[email protected]

- name: Start the dev container
run: |
mkdir -p \
/tmp/.yarn/cache \
/tmp/.cache/R/renv/cache \
/tmp/.cache/pypoetry \
/tmp/.local/share/virtualenv \
/tmp/.gradle/caches \
/tmp/.gradle/wrapper

devcontainer up \
--mount type=bind,source=/tmp/.yarn/cache,target=/workspaces/sage-monorepo/.yarn/cache \
--mount type=bind,source=/tmp/.cache/R/renv/cache,target=/home/vscode/.cache/R/renv/cache \
--mount type=bind,source=/tmp/.cache/pypoetry,target=/home/vscode/.cache/pypoetry \
--mount type=bind,source=/tmp/.local/share/virtualenv,target=/home/vscode/.local/share/virtualenv \
--mount type=bind,source=/tmp/.gradle/caches,target=/home/vscode/.gradle/caches \
--mount type=bind,source=/tmp/.gradle/wrapper,target=/home/vscode/.gradle/wrapper \
--workspace-folder ../sage-monorepo

- name: Prepare the workspace
run: |
devcontainer exec --workspace-folder ../sage-monorepo bash -c "
sudo chown -R vscode:vscode \
/workspaces/sage-monorepo \
/home/vscode/.cache \
/home/vscode/.local \
/home/vscode/.gradle \
&& . ./dev-env.sh \
&& workspace-install"
- uses: ./.github/actions/setup-dev-container

- name: Lint the affected projects
run: |
Expand Down