From a369277478aff1d125b944ae8e1523593e1deb9e Mon Sep 17 00:00:00 2001 From: Cristian Greco Date: Mon, 26 May 2025 09:23:46 +0100 Subject: [PATCH 01/10] Shorten GHA job names --- .github/workflows/test-template.yml | 1 - .github/workflows/test.yml | 6 ++++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-template.yml b/.github/workflows/test-template.yml index 9e077ea0c..59ba140d6 100644 --- a/.github/workflows/test-template.yml +++ b/.github/workflows/test-template.yml @@ -19,7 +19,6 @@ on: jobs: test: - name: "Runner (${{ inputs.runner }}) / Node (${{ inputs.node-version }}) / Runtime (${{ inputs.container-runtime }}) / Workspace (${{ inputs.workspace }})" runs-on: ${{ inputs.runner }} steps: - name: Docker rootless setup 1/2 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9ef9da980..7455705b9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -146,10 +146,11 @@ jobs: fail-fast: false matrix: module: ${{ fromJSON(needs.detect-modules.outputs.modules) }} + ubuntu-version: [22.04] node-version: [20.x, 22.x, 24.x] uses: ./.github/workflows/test-template.yml with: - runner: ubuntu-22.04 + runner: ${{ matrix.ubuntu-version }} node-version: ${{ matrix.node-version }} container-runtime: docker workspace: "${{ matrix.module }}" @@ -167,10 +168,11 @@ jobs: fail-fast: false matrix: module: ${{ fromJSON(needs.detect-modules.outputs.modules) }} + ubuntu-version: [22.04] node-version: [20.x, 22.x, 24.x] uses: ./.github/workflows/test-template.yml with: - runner: ubuntu-22.04 + runner: ${{ matrix.ubuntu-version }} node-version: ${{ matrix.node-version }} container-runtime: podman workspace: "${{ matrix.module }}" From 378a0b67b8311f71d6914dcb87b793a6e7f978df Mon Sep 17 00:00:00 2001 From: Cristian Greco Date: Mon, 26 May 2025 09:31:50 +0100 Subject: [PATCH 02/10] Combine docker/podman as matrix build --- .github/workflows/test-template.yml | 3 --- .github/workflows/test.yml | 29 +++-------------------------- 2 files changed, 3 insertions(+), 29 deletions(-) diff --git a/.github/workflows/test-template.yml b/.github/workflows/test-template.yml index 59ba140d6..3a3f45bb9 100644 --- a/.github/workflows/test-template.yml +++ b/.github/workflows/test-template.yml @@ -1,6 +1,3 @@ -name: Test -run-name: "Runner (${{ inputs.runner }}) / Node (${{ inputs.node-version }}) / Runtime (${{ inputs.container-runtime }}) / Workspace (${{ inputs.workspace }})" - on: workflow_call: inputs: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7455705b9..01fa5e35a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -136,7 +136,7 @@ jobs: test: if: ${{ needs.detect-modules.outputs.modules_count > 0 }} - name: Docker tests + name: Tests needs: - detect-modules - lint @@ -148,33 +148,12 @@ jobs: module: ${{ fromJSON(needs.detect-modules.outputs.modules) }} ubuntu-version: [22.04] node-version: [20.x, 22.x, 24.x] + container-runtime: [docker, podman] uses: ./.github/workflows/test-template.yml with: runner: ${{ matrix.ubuntu-version }} node-version: ${{ matrix.node-version }} - container-runtime: docker - workspace: "${{ matrix.module }}" - - test-podman: - if: ${{ needs.detect-modules.outputs.modules_count > 0 }} - name: Podman tests - needs: - - detect-modules - - lint - - compile - - smoke-test - - test - strategy: - fail-fast: false - matrix: - module: ${{ fromJSON(needs.detect-modules.outputs.modules) }} - ubuntu-version: [22.04] - node-version: [20.x, 22.x, 24.x] - uses: ./.github/workflows/test-template.yml - with: - runner: ${{ matrix.ubuntu-version }} - node-version: ${{ matrix.node-version }} - container-runtime: podman + container-runtime: ${{ matrix.container-runtime }} workspace: "${{ matrix.module }}" end: @@ -186,11 +165,9 @@ jobs: - compile - smoke-test - test - - test-podman runs-on: ubuntu-22.04 steps: - name: Check if any jobs failed if: ${{ failure() || cancelled() }} run: exit 1 - - run: echo "All tests completed successfully!" From 4185483e5ea967a3c7ed4201e9bf0394936ab6ea Mon Sep 17 00:00:00 2001 From: Cristian Greco Date: Mon, 26 May 2025 11:11:31 +0100 Subject: [PATCH 03/10] Do not fail fast lint --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 01fa5e35a..3d4965ca2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -54,7 +54,7 @@ jobs: needs: - detect-modules strategy: - fail-fast: true + fail-fast: false matrix: module: ${{ fromJSON(needs.detect-modules.outputs.modules) }} runs-on: ubuntu-22.04 From 41e6a55ccc23087a18f2b379ec7cc241ca16b0cc Mon Sep 17 00:00:00 2001 From: Cristian Greco Date: Mon, 26 May 2025 18:02:02 +0100 Subject: [PATCH 04/10] Refactor to composite actions --- .github/actions/colima-setup/action.yml | 26 +++++ .../actions/docker-rootless-setup/action.yml | 12 ++ .github/actions/podman-setup/action.yml | 17 +++ .../actions/rancher-desktop-setup/action.yml | 77 +++++++++++++ .github/workflows/test-template.yml | 106 ++---------------- .github/workflows/test.yml | 4 +- 6 files changed, 145 insertions(+), 97 deletions(-) create mode 100644 .github/actions/colima-setup/action.yml create mode 100644 .github/actions/docker-rootless-setup/action.yml create mode 100644 .github/actions/podman-setup/action.yml create mode 100644 .github/actions/rancher-desktop-setup/action.yml diff --git a/.github/actions/colima-setup/action.yml b/.github/actions/colima-setup/action.yml new file mode 100644 index 000000000..9e095c323 --- /dev/null +++ b/.github/actions/colima-setup/action.yml @@ -0,0 +1,26 @@ +name: 'Colima Setup' +description: 'Sets up Colima' +inputs: + runner: + description: 'The runner type (e.g., macos-latest)' + required: true +runs: + using: "composite" + steps: + - name: Colima constraints + shell: bash + run: | + if [[ ! "${{ inputs.runner }}" =~ ^macos.* ]]; then + echo "::error::Colima is only supported on macOS" + exit 1 + fi + - name: Colima setup + shell: bash + run: | + brew install docker docker-compose colima + colima start --cpu 3 --memory 14 --disk 14 --runtime docker + colima status + colima --version + echo "DOCKER_HOST=unix://${HOME}/.colima/default/docker.sock" >> $GITHUB_ENV + echo "TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE=/var/run/docker.sock" >> $GITHUB_ENV + echo "NODE_OPTIONS=--dns-result-order=ipv4first" >> $GITHUB_ENV diff --git a/.github/actions/docker-rootless-setup/action.yml b/.github/actions/docker-rootless-setup/action.yml new file mode 100644 index 000000000..2979bc519 --- /dev/null +++ b/.github/actions/docker-rootless-setup/action.yml @@ -0,0 +1,12 @@ +name: 'Docker Rootless Setup' +description: 'Sets up Docker in rootless mode' +runs: + using: "composite" + steps: + - name: Docker rootless setup 1/2 + uses: ScribeMD/rootless-docker@0.2.2 + - name: Docker rootless setup 2/2 + shell: bash + run: | + sudo rm -rf /var/run/docker.sock + echo "CI_ROOTLESS=true" >> $GITHUB_ENV diff --git a/.github/actions/podman-setup/action.yml b/.github/actions/podman-setup/action.yml new file mode 100644 index 000000000..14a488669 --- /dev/null +++ b/.github/actions/podman-setup/action.yml @@ -0,0 +1,17 @@ +name: 'Podman Setup' +description: 'Sets up Podman' +runs: + using: "composite" + steps: + - name: Podman setup + shell: bash + run: | + curl -fsSL "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable/xUbuntu_$(lsb_release -rs)/Release.key" | gpg --dearmor | sudo tee /etc/apt/keyrings/devel_kubic_libcontainers_unstable.gpg > /dev/null + echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/devel_kubic_libcontainers_unstable.gpg] https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable/xUbuntu_$(lsb_release -rs)/ /" | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:unstable.list > /dev/null + sudo apt-get update + sudo apt-get -y install podman + systemctl enable --now --user podman podman.socket + podman info + echo "DOCKER_HOST=unix://${XDG_RUNTIME_DIR}/podman/podman.sock" >> $GITHUB_ENV + echo "CI_ROOTLESS=true" >> $GITHUB_ENV + echo "CI_PODMAN=true" >> $GITHUB_ENV diff --git a/.github/actions/rancher-desktop-setup/action.yml b/.github/actions/rancher-desktop-setup/action.yml new file mode 100644 index 000000000..bfbca6615 --- /dev/null +++ b/.github/actions/rancher-desktop-setup/action.yml @@ -0,0 +1,77 @@ +name: 'Rancher Desktop Setup' +description: 'Sets up Rancher Desktop' +inputs: + runner: + description: 'The runner type (e.g., macos-latest)' + required: true +runs: + using: "composite" + steps: + - name: Rancher Desktop constraints + shell: bash + run: | + if [[ ! "${{ inputs.runner }}" =~ ^macos.* ]]; then + echo "::error::Rancher Desktop is only supported on macOS" + exit 1 + fi + - name: Rancher Desktop setup + shell: bash + run: | + brew install docker docker-compose + brew install --cask rancher + + TIMEOUT_SECS_CLI_TOOLS=60 + TIMEOUT_SECS_USER_SOCKET=300 + + echo "Open Rancher Desktop app" + open "/Applications/Rancher Desktop.app" + + echo "Wait max of ${TIMEOUT_SECS_CLI_TOOLS}s for Rancher Desktop to create CLI tools" + for i in $(seq 1 ${TIMEOUT_SECS_CLI_TOOLS}); do + if [ -e "$HOME/.rd/bin/rdctl" ]; then + echo "Rancher Desktop CLI tools created after ${i}s" + break + fi + sleep 1 + done + + if [ ! -e "$HOME/.rd/bin/rdctl" ]; then + echo "Rancher Desktop CLI tools not found" + exit 1 + fi + + echo "Rancher Desktop initialised successfully, now configure the container runtime" + $HOME/.rd/bin/rdctl set \ + --container-engine.name=moby \ + --application.admin-access=false \ + --kubernetes.enabled=false \ + --application.start-in-background=true \ + --application.path-management-strategy=manual \ + --virtual-machine.number-cpus=3 \ + --virtual-machine.memory-in-gb=14 \ + || true + + echo "Restart Rancher Desktop" + $HOME/.rd/bin/rdctl shutdown + $HOME/.rd/bin/rdctl start + + echo "Wait max of ${TIMEOUT_SECS_USER_SOCKET}s for Rancher socket" + + for i in $(seq 1 ${TIMEOUT_SECS_USER_SOCKET}); do + if [ -e "$HOME/.rd/docker.sock" ]; then + echo "Rancher Desktop socket created after ${i}s" + break + fi + sleep 1 + done + + if [ ! -e "$HOME/.rd/docker.sock" ]; then + echo "Rancher Desktop socket not found" + exit 1 + fi + + echo "{}" > $HOME/.docker/config.json + + echo "DOCKER_HOST=unix://${HOME}/.rd/docker.sock" >> $GITHUB_ENV + echo "TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE=/var/run/docker.sock" >> $GITHUB_ENV + echo "NODE_OPTIONS=--dns-result-order=ipv4first" >> $GITHUB_ENV diff --git a/.github/workflows/test-template.yml b/.github/workflows/test-template.yml index 3a3f45bb9..cf8ccb908 100644 --- a/.github/workflows/test-template.yml +++ b/.github/workflows/test-template.yml @@ -18,110 +18,25 @@ jobs: test: runs-on: ${{ inputs.runner }} steps: - - name: Docker rootless setup 1/2 + - name: Docker rootless setup if: ${{ inputs.container-runtime == 'docker-rootless' }} - uses: ScribeMD/rootless-docker@0.2.2 - - name: Docker rootless setup 2/2 - if: ${{ inputs.container-runtime == 'docker-rootless' }} - run: | - sudo rm -rf /var/run/docker.sock - echo "CI_ROOTLESS=true" >> $GITHUB_ENV + uses: ./.github/actions/docker-rootless-setup - name: Podman setup if: ${{ inputs.container-runtime == 'podman' }} - run: | - curl -fsSL "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable/xUbuntu_$(lsb_release -rs)/Release.key" | gpg --dearmor | sudo tee /etc/apt/keyrings/devel_kubic_libcontainers_unstable.gpg > /dev/null - echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/devel_kubic_libcontainers_unstable.gpg] https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable/xUbuntu_$(lsb_release -rs)/ /" | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:unstable.list > /dev/null - sudo apt-get update - sudo apt-get -y install podman - systemctl enable --now --user podman podman.socket - podman info - echo "DOCKER_HOST=unix://${XDG_RUNTIME_DIR}/podman/podman.sock" >> $GITHUB_ENV - echo "CI_ROOTLESS=true" >> $GITHUB_ENV - echo "CI_PODMAN=true" >> $GITHUB_ENV + uses: ./.github/actions/podman-setup - - name: Colima constraints - if: ${{ inputs.container-runtime == 'colima' && !startsWith(inputs.runner, 'macos') }} - run: | - run: echo "::error::Colima is only supported on macOS" - exit 1 - name: Colima setup if: ${{ inputs.container-runtime == 'colima' }} - run: | - brew install docker docker-compose colima - colima start --cpu 3 --memory 14 --disk 14 --runtime docker - colima status - colima --version - echo "DOCKER_HOST=unix://${HOME}/.colima/default/docker.sock" >> $GITHUB_ENV - echo "TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE=/var/run/docker.sock" >> $GITHUB_ENV - echo "NODE_OPTIONS=--dns-result-order=ipv4first" >> $GITHUB_ENV + uses: ./.github/actions/colima-setup + with: + runner: ${{ inputs.runner }} - - name: Rancher Desktop constraints - if: ${{ inputs.container-runtime == 'rancher-desktop' && !startsWith(inputs.runner, 'macos') }} - run: | - run: echo "::error::Rancher Desktop is only supported on macOS" - exit 1 - name: Rancher Desktop setup if: ${{ inputs.container-runtime == 'rancher-desktop' }} - run: | - brew install docker docker-compose - brew install --cask rancher - - TIMEOUT_SECS_CLI_TOOLS=60 - TIMEOUT_SECS_USER_SOCKET=300 - - echo "Open Rancher Desktop app" - open "/Applications/Rancher Desktop.app" - - echo "Wait max of ${TIMEOUT_SECS_CLI_TOOLS}s for Rancher Desktop to create CLI tools" - for i in $(seq 1 ${TIMEOUT_SECS_CLI_TOOLS}); do - if [ -e "$HOME/.rd/bin/rdctl" ]; then - echo "Rancher Desktop CLI tools created after ${i}s" - break - fi - sleep 1 - done - - if [ ! -e "$HOME/.rd/bin/rdctl" ]; then - echo "Rancher Desktop CLI tools not found" - exit 1 - fi - - echo "Rancher Desktop initialised successfully, now configure the container runtime" - $HOME/.rd/bin/rdctl set \ - --container-engine.name=moby \ - --application.admin-access=false \ - --kubernetes.enabled=false \ - --application.start-in-background=true \ - --application.path-management-strategy=manual \ - --virtual-machine.number-cpus=3 \ - --virtual-machine.memory-in-gb=14 \ - || true - - echo "Restart Rancher Desktop" - $HOME/.rd/bin/rdctl shutdown - $HOME/.rd/bin/rdctl start - - echo "Wait max of ${TIMEOUT_SECS_USER_SOCKET}s for Rancher socket" - - for i in $(seq 1 ${TIMEOUT_SECS_USER_SOCKET}); do - if [ -e "$HOME/.rd/docker.sock" ]; then - echo "Rancher Desktop socket created after ${i}s" - break - fi - sleep 1 - done - - if [ ! -e "$HOME/.rd/docker.sock" ]; then - echo "Rancher Desktop socket not found" - exit 1 - fi - - echo "{}" > $HOME/.docker/config.json - - echo "DOCKER_HOST=unix://${HOME}/.rd/docker.sock" >> $GITHUB_ENV - echo "TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE=/var/run/docker.sock" >> $GITHUB_ENV - echo "NODE_OPTIONS=--dns-result-order=ipv4first" >> $GITHUB_ENV + uses: ./.github/actions/rancher-desktop-setup + with: + runner: ${{ inputs.runner }} - name: Code checkout uses: actions/checkout@v4 @@ -135,4 +50,5 @@ jobs: workspace: "${{ inputs.workspace }}" - name: Run tests - run: npm run test:ci -- --coverage.include=${{ steps.npm-install.outputs.workspace_path }} ${{ steps.npm-install.outputs.workspace_path }} + run: + npm run test:ci -- --coverage.include=${{ steps.npm-install.outputs.workspace_path }} ${{ steps.npm-install.outputs.workspace_path }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3d4965ca2..fe2d0a9a3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -62,7 +62,7 @@ jobs: - name: Code checkout uses: actions/checkout@v4 - name: Install Node and Dependencies - id: npm-install + id: npm-install-modules uses: ./.github/actions/npm-setup with: runner: ubuntu-22.04 @@ -70,7 +70,7 @@ jobs: workspace: "${{ matrix.module }}" - name: Code linting env: - WORKSPACE_PATH: ${{ steps.npm-install.outputs.workspace_path }} + WORKSPACE_PATH: ${{ steps.npm-install-modules.outputs.workspace_path }} run: npm run lint:ci compile: From 92c881ebb8bae82eceecd8f8a96401b786c7b7ae Mon Sep 17 00:00:00 2001 From: Cristian Greco Date: Mon, 26 May 2025 18:05:00 +0100 Subject: [PATCH 05/10] Include .github YAMLs in formatter + format --- .github/actions/colima-setup/action.yml | 6 +- .../actions/docker-rootless-setup/action.yml | 4 +- .github/actions/npm-setup/action.yml | 100 +++++++++--------- .github/actions/podman-setup/action.yml | 4 +- .../actions/rancher-desktop-setup/action.yml | 6 +- .github/release-drafter.yml | 34 +++--- .github/workflows/codeql-analysis.yml | 29 +++-- .github/workflows/test-template.yml | 3 +- .github/workflows/windows-test.yml | 2 +- package.json | 2 +- 10 files changed, 94 insertions(+), 96 deletions(-) diff --git a/.github/actions/colima-setup/action.yml b/.github/actions/colima-setup/action.yml index 9e095c323..2839c0de4 100644 --- a/.github/actions/colima-setup/action.yml +++ b/.github/actions/colima-setup/action.yml @@ -1,8 +1,8 @@ -name: 'Colima Setup' -description: 'Sets up Colima' +name: "Colima Setup" +description: "Sets up Colima" inputs: runner: - description: 'The runner type (e.g., macos-latest)' + description: "The runner type (e.g., macos-latest)" required: true runs: using: "composite" diff --git a/.github/actions/docker-rootless-setup/action.yml b/.github/actions/docker-rootless-setup/action.yml index 2979bc519..e0c640a80 100644 --- a/.github/actions/docker-rootless-setup/action.yml +++ b/.github/actions/docker-rootless-setup/action.yml @@ -1,5 +1,5 @@ -name: 'Docker Rootless Setup' -description: 'Sets up Docker in rootless mode' +name: "Docker Rootless Setup" +description: "Sets up Docker in rootless mode" runs: using: "composite" steps: diff --git a/.github/actions/npm-setup/action.yml b/.github/actions/npm-setup/action.yml index e8325e5a6..7d924eb20 100644 --- a/.github/actions/npm-setup/action.yml +++ b/.github/actions/npm-setup/action.yml @@ -1,68 +1,68 @@ -name: 'NPM Setup' -description: 'Sets up Node.js and installs NPM dependencies with caching' +name: "NPM Setup" +description: "Sets up Node.js and installs NPM dependencies with caching" inputs: runner: - description: 'Runner to use' + description: "Runner to use" required: true node-version: - description: 'Node.js version to use' + description: "Node.js version to use" required: true workspace: - description: 'Key for the cache' + description: "Key for the cache" required: true outputs: workspace_path: description: "Full path to the workspace directory" value: ${{ steps.set-env.outputs.workspace_path }} - + runs: using: "composite" steps: - - name: Install NodeJS ${{ inputs.node-version }} - uses: actions/setup-node@v4 - with: - node-version: ${{ inputs.node-version }} - - - name: Set cache configuration - shell: bash - id: set-env - run: | - if [ "${{ inputs.workspace }}" = "testcontainers" ]; then - echo "CACHE_PATHS<> $GITHUB_ENV - echo "node_modules" >> $GITHUB_ENV - echo "packages/testcontainers/node_modules" >> $GITHUB_ENV - echo "EOF" >> $GITHUB_ENV - echo "WORKSPACE_PATH=packages/testcontainers" >> $GITHUB_ENV - echo "workspace_path=packages/testcontainers" >> "$GITHUB_OUTPUT" - else - echo "CACHE_PATHS<> $GITHUB_ENV - echo "node_modules" >> $GITHUB_ENV - echo "packages/testcontainers/node_modules" >> $GITHUB_ENV - echo "packages/modules/${{ inputs.workspace }}/node_modules" >> $GITHUB_ENV - echo "EOF" >> $GITHUB_ENV - echo "WORKSPACE_PATH=packages/modules/${{ inputs.workspace }}" >> $GITHUB_ENV - echo "workspace_path=packages/modules/${{ inputs.workspace }}" >> "$GITHUB_OUTPUT" - fi - - - uses: actions/cache/restore@v4 - id: npm-cache - with: - path: ${{ env.CACHE_PATHS }} - key: ${{ inputs.runner }}-node-${{ inputs.node-version }}-${{ inputs.workspace }}-${{ hashFiles('package-lock.json', 'packages/testcontainers/package-lock.json', format('packages/modules/{0}/package-lock.json', inputs.workspace)) }} - restore-keys: | - ${{ inputs.runner }}-node-${{ inputs.node-version }}-${{ inputs.workspace }}- - ${{ inputs.runner }}-node-${{ inputs.node-version }}- + - name: Install NodeJS ${{ inputs.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ inputs.node-version }} + + - name: Set cache configuration + shell: bash + id: set-env + run: | + if [ "${{ inputs.workspace }}" = "testcontainers" ]; then + echo "CACHE_PATHS<> $GITHUB_ENV + echo "node_modules" >> $GITHUB_ENV + echo "packages/testcontainers/node_modules" >> $GITHUB_ENV + echo "EOF" >> $GITHUB_ENV + echo "WORKSPACE_PATH=packages/testcontainers" >> $GITHUB_ENV + echo "workspace_path=packages/testcontainers" >> "$GITHUB_OUTPUT" + else + echo "CACHE_PATHS<> $GITHUB_ENV + echo "node_modules" >> $GITHUB_ENV + echo "packages/testcontainers/node_modules" >> $GITHUB_ENV + echo "packages/modules/${{ inputs.workspace }}/node_modules" >> $GITHUB_ENV + echo "EOF" >> $GITHUB_ENV + echo "WORKSPACE_PATH=packages/modules/${{ inputs.workspace }}" >> $GITHUB_ENV + echo "workspace_path=packages/modules/${{ inputs.workspace }}" >> "$GITHUB_OUTPUT" + fi + + - uses: actions/cache/restore@v4 + id: npm-cache + with: + path: ${{ env.CACHE_PATHS }} + key: ${{ inputs.runner }}-node-${{ inputs.node-version }}-${{ inputs.workspace }}-${{ hashFiles('package-lock.json', 'packages/testcontainers/package-lock.json', format('packages/modules/{0}/package-lock.json', inputs.workspace)) }} + restore-keys: | + ${{ inputs.runner }}-node-${{ inputs.node-version }}-${{ inputs.workspace }}- + ${{ inputs.runner }}-node-${{ inputs.node-version }}- - - name: Install dependencies - if: steps.npm-cache.outputs.cache-hit != 'true' - shell: bash - run: npm ci --workspace ${{ env.WORKSPACE_PATH }} --include-workspace-root + - name: Install dependencies + if: steps.npm-cache.outputs.cache-hit != 'true' + shell: bash + run: npm ci --workspace ${{ env.WORKSPACE_PATH }} --include-workspace-root - - name: Cache npm - if: steps.npm-cache.outputs.cache-hit != 'true' - uses: actions/cache/save@v4 - with: - path: ${{ env.CACHE_PATHS }} - key: ${{ steps.npm-cache.outputs.cache-primary-key }} + - name: Cache npm + if: steps.npm-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@v4 + with: + path: ${{ env.CACHE_PATHS }} + key: ${{ steps.npm-cache.outputs.cache-primary-key }} diff --git a/.github/actions/podman-setup/action.yml b/.github/actions/podman-setup/action.yml index 14a488669..99b07a35d 100644 --- a/.github/actions/podman-setup/action.yml +++ b/.github/actions/podman-setup/action.yml @@ -1,5 +1,5 @@ -name: 'Podman Setup' -description: 'Sets up Podman' +name: "Podman Setup" +description: "Sets up Podman" runs: using: "composite" steps: diff --git a/.github/actions/rancher-desktop-setup/action.yml b/.github/actions/rancher-desktop-setup/action.yml index bfbca6615..0407b43e9 100644 --- a/.github/actions/rancher-desktop-setup/action.yml +++ b/.github/actions/rancher-desktop-setup/action.yml @@ -1,8 +1,8 @@ -name: 'Rancher Desktop Setup' -description: 'Sets up Rancher Desktop' +name: "Rancher Desktop Setup" +description: "Sets up Rancher Desktop" inputs: runner: - description: 'The runner type (e.g., macos-latest)' + description: "The runner type (e.g., macos-latest)" required: true runs: using: "composite" diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index fcb7fb5c8..c47f251fe 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -1,35 +1,35 @@ -name-template: 'v$RESOLVED_VERSION' -tag-template: 'v$RESOLVED_VERSION' +name-template: "v$RESOLVED_VERSION" +tag-template: "v$RESOLVED_VERSION" categories: - - title: '๐Ÿš€ Features' + - title: "๐Ÿš€ Features" labels: - - 'enhancement' - - title: '๐Ÿ› Bug Fixes' + - "enhancement" + - title: "๐Ÿ› Bug Fixes" labels: - - 'bug' - - title: '๐Ÿ“– Documentation' + - "bug" + - title: "๐Ÿ“– Documentation" labels: - - 'documentation' - - title: '๐Ÿงน Maintenance' + - "documentation" + - title: "๐Ÿงน Maintenance" labels: - - 'maintenance' - - title: '๐Ÿ“ฆ Dependency Updates' + - "maintenance" + - title: "๐Ÿ“ฆ Dependency Updates" labels: - - 'dependencies' -change-template: '- $TITLE @$AUTHOR (#$NUMBER)' + - "dependencies" +change-template: "- $TITLE @$AUTHOR (#$NUMBER)" change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks. version-resolver: major: labels: - - 'major' + - "major" minor: labels: - - 'minor' + - "minor" patch: labels: - - 'patch' + - "patch" default: patch template: | ## Changes - $CHANGES \ No newline at end of file + $CHANGES diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index f2f3e70d4..6cfa30e26 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -2,12 +2,12 @@ name: "CodeQL" on: push: - branches: [ main ] + branches: [main] pull_request: # The branches below must be a subset of the branches above - branches: [ main ] + branches: [main] schedule: - - cron: '17 5 * * 2' + - cron: "17 5 * * 2" jobs: analyze: @@ -20,17 +20,16 @@ jobs: strategy: fail-fast: false matrix: - language: [ 'javascript' ] + language: ["javascript"] steps: - - name: Checkout repository - uses: actions/checkout@v4 - - name: Initialize CodeQL - uses: github/codeql-action/init@v3 - with: - languages: ${{ matrix.language }} - - name: Autobuild - uses: github/codeql-action/autobuild@v3 - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v3 - + - name: Checkout repository + uses: actions/checkout@v4 + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + with: + languages: ${{ matrix.language }} + - name: Autobuild + uses: github/codeql-action/autobuild@v3 + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 diff --git a/.github/workflows/test-template.yml b/.github/workflows/test-template.yml index cf8ccb908..c677879ac 100644 --- a/.github/workflows/test-template.yml +++ b/.github/workflows/test-template.yml @@ -50,5 +50,4 @@ jobs: workspace: "${{ inputs.workspace }}" - name: Run tests - run: - npm run test:ci -- --coverage.include=${{ steps.npm-install.outputs.workspace_path }} ${{ steps.npm-install.outputs.workspace_path }} + run: npm run test:ci -- --coverage.include=${{ steps.npm-install.outputs.workspace_path }} ${{ steps.npm-install.outputs.workspace_path }} diff --git a/.github/workflows/windows-test.yml b/.github/workflows/windows-test.yml index 18a0f9097..975b25588 100644 --- a/.github/workflows/windows-test.yml +++ b/.github/workflows/windows-test.yml @@ -76,4 +76,4 @@ jobs: target_url: `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`, context: 'Test Windows', }); - } \ No newline at end of file + } diff --git a/package.json b/package.json index b77f07fb2..9d5c21ba6 100755 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "docs:serve": "docker-compose up", "test": "vitest run", "test:ci": "npm run test -- --coverage", - "format": "prettier --write package.json \"packages/**/*.ts\"", + "format": "prettier --write package.json \"packages/**/*.ts\" \".github/**/*.yml\"", "lint": "eslint --fix package.json \"packages/**/*.ts\"", "lint:ci": "eslint package.json \"${WORKSPACE_PATH}/**/*.ts\" --max-warnings=0", "update-deps": "npm-check-updates --workspaces --root -u", From 861a7d0d7c720bafe1cbc656b9ba7ffe067db68f Mon Sep 17 00:00:00 2001 From: Cristian Greco Date: Mon, 26 May 2025 18:16:26 +0100 Subject: [PATCH 06/10] Rename test.yml to checks.yml --- .github/workflows/{test.yml => checks.yml} | 6 ------ README.md | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) rename .github/workflows/{test.yml => checks.yml} (99%) diff --git a/.github/workflows/test.yml b/.github/workflows/checks.yml similarity index 99% rename from .github/workflows/test.yml rename to .github/workflows/checks.yml index fe2d0a9a3..232b29bc5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/checks.yml @@ -28,21 +28,17 @@ jobs: steps: - name: Check out code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - id: changed-files name: Get changed files uses: tj-actions/changed-files@ed68ef82c095e0d48ec87eccea555d944a631a4c # v46.0.5 - - id: set-modified-modules name: Set all modified modules env: ALL_CHANGED_FILES: "${{ steps.changed-files.outputs.all_changed_files }}" run: echo "modules=$(./.github/scripts/changed-modules.sh)" >> $GITHUB_OUTPUT - - id: set-modified-modules-count name: Set all modified modules count run: echo "modules_count=$(echo ${{ toJSON(steps.set-modified-modules.outputs.modules) }} | jq '. | length')" >> $GITHUB_OUTPUT - - name: Print out the modules to be used run: | echo "${{ steps.set-modified-modules-count.outputs.modules_count }} modules in the build" @@ -117,14 +113,12 @@ jobs: steps: - name: Code checkout uses: actions/checkout@v4 - - name: Install Node ${{ matrix.node-version }} and Dependencies uses: ./.github/actions/npm-setup with: runner: ${{ matrix.runner }} node-version: ${{ matrix.node-version }} workspace: "testcontainers" - - name: Build testcontainers run: npm run build --workspace packages/testcontainers - name: Remove dev dependencies diff --git a/README.md b/README.md index 6d9786778..9bb0d7217 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://github.com/codespaces/new?hide_repo_select=true&ref=main&repo=116414510&machine=standardLinux32gb&devcontainer_path=.devcontainer%2Fdevcontainer.json&location=EastUs) -[![Test](https://github.com/testcontainers/testcontainers-node/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/testcontainers/testcontainers-node/actions/workflows/test.yml) +[![Test](https://github.com/testcontainers/testcontainers-node/actions/workflows/checks.yml/badge.svg?branch=main)](https://github.com/testcontainers/testcontainers-node/actions/workflows/checks.yml) [![npm version](https://badge.fury.io/js/testcontainers.svg)](https://www.npmjs.com/package/testcontainers) [![npm version](https://img.shields.io/npm/dm/testcontainers.svg)](https://www.npmjs.com/package/testcontainers) From a00dcdfce85110ceffee4636c94ca88025995fce Mon Sep 17 00:00:00 2001 From: Cristian Greco Date: Mon, 26 May 2025 19:57:52 +0100 Subject: [PATCH 07/10] Fix runner var --- .github/workflows/checks.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 232b29bc5..5d1eb7244 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -140,12 +140,12 @@ jobs: fail-fast: false matrix: module: ${{ fromJSON(needs.detect-modules.outputs.modules) }} - ubuntu-version: [22.04] + runner: [ubuntu-22.04] node-version: [20.x, 22.x, 24.x] container-runtime: [docker, podman] uses: ./.github/workflows/test-template.yml with: - runner: ${{ matrix.ubuntu-version }} + runner: ${{ matrix.runner }} node-version: ${{ matrix.node-version }} container-runtime: ${{ matrix.container-runtime }} workspace: "${{ matrix.module }}" From 79ae8cadcf893160f5040affb4680694facfb3ac Mon Sep 17 00:00:00 2001 From: Cristian Greco Date: Mon, 26 May 2025 20:03:43 +0100 Subject: [PATCH 08/10] Checkout codebase to find composite actions --- .github/workflows/test-template.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test-template.yml b/.github/workflows/test-template.yml index c677879ac..cbbf2c9ff 100644 --- a/.github/workflows/test-template.yml +++ b/.github/workflows/test-template.yml @@ -18,6 +18,9 @@ jobs: test: runs-on: ${{ inputs.runner }} steps: + - name: Code checkout + uses: actions/checkout@v4 + - name: Docker rootless setup if: ${{ inputs.container-runtime == 'docker-rootless' }} uses: ./.github/actions/docker-rootless-setup From 33134d79610f2c8f56ac008548184ca45d9b6fe9 Mon Sep 17 00:00:00 2001 From: Cristian Greco Date: Mon, 26 May 2025 20:12:20 +0100 Subject: [PATCH 09/10] Minor cleanup --- .github/workflows/checks.yml | 3 +-- .github/workflows/test-template.yml | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 5d1eb7244..a4dac2291 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -140,12 +140,11 @@ jobs: fail-fast: false matrix: module: ${{ fromJSON(needs.detect-modules.outputs.modules) }} - runner: [ubuntu-22.04] node-version: [20.x, 22.x, 24.x] container-runtime: [docker, podman] uses: ./.github/workflows/test-template.yml with: - runner: ${{ matrix.runner }} + runner: ubuntu-22.04 node-version: ${{ matrix.node-version }} container-runtime: ${{ matrix.container-runtime }} workspace: "${{ matrix.module }}" diff --git a/.github/workflows/test-template.yml b/.github/workflows/test-template.yml index cbbf2c9ff..8c33429b8 100644 --- a/.github/workflows/test-template.yml +++ b/.github/workflows/test-template.yml @@ -16,6 +16,7 @@ on: jobs: test: + name: "Run" runs-on: ${{ inputs.runner }} steps: - name: Code checkout From 6db4c7213dec26fe19a604d809fbf05e2192d0f9 Mon Sep 17 00:00:00 2001 From: Cristian Greco Date: Mon, 26 May 2025 20:32:18 +0100 Subject: [PATCH 10/10] Minor cleanup --- .github/workflows/checks.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index a4dac2291..2e1d25818 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -105,18 +105,17 @@ jobs: - compile name: Smoke tests strategy: - fail-fast: true + fail-fast: false matrix: - runner: [ubuntu-22.04] node-version: [20.x, 22.x, 24.x] - runs-on: ${{ matrix.runner }} + runs-on: ubuntu-22.04 steps: - name: Code checkout uses: actions/checkout@v4 - name: Install Node ${{ matrix.node-version }} and Dependencies uses: ./.github/actions/npm-setup with: - runner: ${{ matrix.runner }} + runner: ubuntu-22.04 node-version: ${{ matrix.node-version }} workspace: "testcontainers" - name: Build testcontainers