From 5e1bd877b6e5384ef566c9ecf3eae6478ad5a41c Mon Sep 17 00:00:00 2001 From: Thomas Schaffter Date: Tue, 23 Jan 2024 17:48:46 +0000 Subject: [PATCH 1/5] Create a composite action to setup the dev container --- .../actions/setup-dev-container/action.yml | 77 +++++++++ .github/workflows/ci.yml | 146 +----------------- 2 files changed, 79 insertions(+), 144 deletions(-) create mode 100644 .github/actions/setup-dev-container/action.yml diff --git a/.github/actions/setup-dev-container/action.yml b/.github/actions/setup-dev-container/action.yml new file mode 100644 index 0000000000..c03b89a96a --- /dev/null +++ b/.github/actions/setup-dev-container/action.yml @@ -0,0 +1,77 @@ +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 + run: npm install -g @devcontainers/cli@0.49.0 + + - 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" \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 27d2ba56a0..e6a32771e1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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/cli@0.49.0 - - - 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: | @@ -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/cli@0.49.0 - - - 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: | From 4976b76dfa0ecbef960edcf92ced829e1d54aafb Mon Sep 17 00:00:00 2001 From: Thomas Schaffter Date: Tue, 23 Jan 2024 17:57:04 +0000 Subject: [PATCH 2/5] Add shell --- .github/actions/setup-dev-container/action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/actions/setup-dev-container/action.yml b/.github/actions/setup-dev-container/action.yml index c03b89a96a..6b3b2e7010 100644 --- a/.github/actions/setup-dev-container/action.yml +++ b/.github/actions/setup-dev-container/action.yml @@ -44,6 +44,7 @@ runs: ${{ runner.os }}-gradle- - name: Install the Dev Container CLI + shell: bash run: npm install -g @devcontainers/cli@0.49.0 - name: Start the dev container From 816c7624f58ea716f85ba6befdb5ac6bbb95ba15 Mon Sep 17 00:00:00 2001 From: Thomas Schaffter Date: Tue, 23 Jan 2024 17:58:23 +0000 Subject: [PATCH 3/5] Add shell --- .github/actions/setup-dev-container/action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/actions/setup-dev-container/action.yml b/.github/actions/setup-dev-container/action.yml index 6b3b2e7010..7ed051dc50 100644 --- a/.github/actions/setup-dev-container/action.yml +++ b/.github/actions/setup-dev-container/action.yml @@ -67,6 +67,7 @@ runs: --workspace-folder ../sage-monorepo - name: Prepare the workspace + shell: bash run: | devcontainer exec --workspace-folder ../sage-monorepo bash -c " sudo chown -R vscode:vscode \ From ad3d36eafd13bf5b821757ce7f76b22175159c48 Mon Sep 17 00:00:00 2001 From: Thomas Schaffter Date: Tue, 23 Jan 2024 18:03:14 +0000 Subject: [PATCH 4/5] Fix indent --- .../actions/setup-dev-container/action.yml | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/actions/setup-dev-container/action.yml b/.github/actions/setup-dev-container/action.yml index 7ed051dc50..882b79e224 100644 --- a/.github/actions/setup-dev-container/action.yml +++ b/.github/actions/setup-dev-container/action.yml @@ -66,14 +66,14 @@ runs: --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" \ No newline at end of file + - 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" From 09f8349a4f0b3c6e7138ac9dc3b523e7ce5b7a43 Mon Sep 17 00:00:00 2001 From: Thomas Schaffter Date: Tue, 23 Jan 2024 18:06:24 +0000 Subject: [PATCH 5/5] Add shell --- .github/actions/setup-dev-container/action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/actions/setup-dev-container/action.yml b/.github/actions/setup-dev-container/action.yml index 882b79e224..2ee0fc76d2 100644 --- a/.github/actions/setup-dev-container/action.yml +++ b/.github/actions/setup-dev-container/action.yml @@ -48,6 +48,7 @@ runs: run: npm install -g @devcontainers/cli@0.49.0 - name: Start the dev container + shell: bash run: | mkdir -p \ /tmp/.yarn/cache \