From be38ab862a8884b96e39623b30d4c0a370feedbf Mon Sep 17 00:00:00 2001 From: Cristian Greco Date: Fri, 15 May 2026 16:30:13 +0100 Subject: [PATCH 1/2] Simplify affected package checks --- .github/actions/colima-setup/action.yml | 26 --- .../actions/docker-rootless-setup/action.yml | 12 -- .github/actions/npm-setup/action.yml | 57 +++---- .../actions/rancher-desktop-setup/action.yml | 77 --------- .github/scripts/changed-modules.mjs | 65 ++++++++ .github/scripts/changed-modules.sh | 148 ------------------ .github/workflows/checks.yml | 51 +++--- .github/workflows/test-template.yml | 19 --- .../windows-test-command-dispatch.yml | 19 --- .github/workflows/windows-test.yml | 79 ---------- package.json | 4 +- 11 files changed, 121 insertions(+), 436 deletions(-) delete mode 100644 .github/actions/colima-setup/action.yml delete mode 100644 .github/actions/docker-rootless-setup/action.yml delete mode 100644 .github/actions/rancher-desktop-setup/action.yml create mode 100644 .github/scripts/changed-modules.mjs delete mode 100755 .github/scripts/changed-modules.sh delete mode 100644 .github/workflows/windows-test-command-dispatch.yml delete mode 100644 .github/workflows/windows-test.yml diff --git a/.github/actions/colima-setup/action.yml b/.github/actions/colima-setup/action.yml deleted file mode 100644 index 2839c0de4..000000000 --- a/.github/actions/colima-setup/action.yml +++ /dev/null @@ -1,26 +0,0 @@ -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 deleted file mode 100644 index e0c640a80..000000000 --- a/.github/actions/docker-rootless-setup/action.yml +++ /dev/null @@ -1,12 +0,0 @@ -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/npm-setup/action.yml b/.github/actions/npm-setup/action.yml index 215b06cbb..20f8b6955 100644 --- a/.github/actions/npm-setup/action.yml +++ b/.github/actions/npm-setup/action.yml @@ -9,57 +9,50 @@ inputs: description: "Node.js version to use" required: true workspace: - description: "Key for the cache" + description: "Workspace to install" required: true outputs: workspace_path: description: "Full path to the workspace directory" - value: ${{ steps.set-env.outputs.workspace_path }} + value: ${{ steps.set-workspace.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 + - name: Set workspace path shell: bash - id: set-env + id: set-workspace 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" + workspace_path="packages/testcontainers" + cache_paths=$'node_modules\npackages/testcontainers/node_modules' 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" + workspace_path="packages/modules/${{ inputs.workspace }}" + cache_paths=$'node_modules\npackages/testcontainers/node_modules\n'"${workspace_path}/node_modules" fi - - uses: actions/cache/restore@v4 + echo "WORKSPACE_PATH=${workspace_path}" >> "$GITHUB_ENV" + echo "workspace_path=${workspace_path}" >> "$GITHUB_OUTPUT" + { + echo "cache_paths<> "$GITHUB_OUTPUT" + + - name: Install NodeJS ${{ inputs.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ inputs.node-version }} + + - name: Cache dependencies + uses: actions/cache@v4 id: npm-cache with: - path: ${{ env.CACHE_PATHS }} + path: ${{ steps.set-workspace.outputs.cache_paths }} key: ${{ inputs.runner }}-node-${{ inputs.node-version }}-${{ inputs.workspace }}-${{ hashFiles('package-lock.json') }} - 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 }} + run: npm ci --workspace "${WORKSPACE_PATH}" --include-workspace-root diff --git a/.github/actions/rancher-desktop-setup/action.yml b/.github/actions/rancher-desktop-setup/action.yml deleted file mode 100644 index 0407b43e9..000000000 --- a/.github/actions/rancher-desktop-setup/action.yml +++ /dev/null @@ -1,77 +0,0 @@ -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/scripts/changed-modules.mjs b/.github/scripts/changed-modules.mjs new file mode 100644 index 000000000..4b69d8289 --- /dev/null +++ b/.github/scripts/changed-modules.mjs @@ -0,0 +1,65 @@ +import { existsSync, readdirSync, readFileSync } from "node:fs"; +import { dirname, resolve } from "node:path"; +import process from "node:process"; +import { fileURLToPath } from "node:url"; + +const rootDir = resolve(dirname(fileURLToPath(import.meta.url)), "../.."); + +const ignoredPaths = [ + /^README\.md$/, + /^docs\//, + /^mkdocs\.yml$/, + /^\.github\/FUNDING\.yml$/, + /^\.github\/ISSUE_TEMPLATE\//, + /^\.github\/release-drafter\.yml$/, +]; + +const allPackagesPaths = [ + /^packages\/testcontainers\//, + /^package(-lock)?\.json$/, + /^tsconfig\.base\.json$/, + /^eslint\.config\.js$/, + /^vitest\.config\.ts$/, + /^\.npmrc$/, + /^\.github\/actions\//, + /^\.github\/scripts\//, + /^\.github\/workflows\/(checks|test-template)\.yml$/, +]; + +const changedFiles = readFileSync(0, "utf8") + .split(/\r?\n/) + .map((file) => file.trim()) + .filter(Boolean); + +const modulesDir = resolve(rootDir, "packages/modules"); +const moduleNames = new Set( + readdirSync(modulesDir, { withFileTypes: true }) + .filter((entry) => entry.isDirectory()) + .filter((entry) => existsSync(resolve(modulesDir, entry.name, "package.json"))) + .map((entry) => entry.name) +); + +const allPackages = () => ["testcontainers", ...moduleNames].sort(); +const selectedPackages = new Set(); + +for (const file of changedFiles) { + if (ignoredPaths.some((pattern) => pattern.test(file))) { + continue; + } + + const moduleMatch = file.match(/^packages\/modules\/([^/]+)\//); + if (moduleMatch) { + const moduleName = moduleMatch[1]; + if (moduleNames.has(moduleName)) { + selectedPackages.add(moduleName); + } + continue; + } + + if (allPackagesPaths.some((pattern) => pattern.test(file))) { + process.stdout.write(`${JSON.stringify(allPackages())}\n`); + process.exit(0); + } +} + +process.stdout.write(`${JSON.stringify([...selectedPackages].sort())}\n`); diff --git a/.github/scripts/changed-modules.sh b/.github/scripts/changed-modules.sh deleted file mode 100755 index 34c0439de..000000000 --- a/.github/scripts/changed-modules.sh +++ /dev/null @@ -1,148 +0,0 @@ -#!/usr/bin/env bash - -# exit on error, unset variables, print commands, fail on pipe errors -set -euxo pipefail - -# How to test this script, run it with the required environment variables: -# 1. A modified file from the root, but not the package.json or package-lock.json: -# ALL_CHANGED_FILES="README.md" ./.github/scripts/changed-modules.sh -# Expected output: [], as no module should be built -# -# 2. The package.json or package-lock.json are modified: -# ALL_CHANGED_FILES="package.json" ./.github/scripts/changed-modules.sh -# Expected output: all modules, as the dependencies have been modified -# ALL_CHANGED_FILES="package-lock.json" ./.github/scripts/changed-modules.sh -# Expected output: all modules, as the dependencies have been modified -# -# 3. A file in the testcontainers module is modified: -# ALL_CHANGED_FILES="packages/testcontainers/a.txt" ./.github/scripts/changed-modules.sh -# Expected output: all modules, as the core has been modified -# -# 4. A file in a module is modified: -# ALL_CHANGED_FILES="packages/modules/arangodb/a.txt" ./.github/scripts/changed-modules.sh -# Expected output: [arangodb], only -# -# 5. Three files in three different modules are modified: -# ALL_CHANGED_FILES="packages/modules/arangodb/a.txt packages/modules/cassandra/b.txt packages/modules/chromadb/c.txt" ./.github/scripts/changed-modules.sh -# Expected output: [arangodb, cassandra, chromadb] -# -# 6. Core files and module files are modified: -# ALL_CHANGED_FILES="packages/testcontainers/a.txt packages/modules/chromadb/b.txt" ./.github/scripts/changed-modules.sh -# Expected output: all modules, as the core has been modified -# -# 7. This script is modified: -# ALL_CHANGED_FILES=".github/scripts/changed-modules.sh" ./.github/scripts/changed-modules.sh -# Expected output: all modules, as the build script has been modified -# -# 8. A .github file is modified: -# ALL_CHANGED_FILES=".github/release-drafter.yml" ./.github/scripts/changed-modules.sh -# Expected output: [] -# -# 9. A excluded module is modified: -# ALL_CHANGED_FILES="packages/modules/couchbase/a.txt" ./.github/scripts/changed-modules.sh -# Expected output: [] -# -# There is room for improvement in this script. For example, it could detect if the changes applied to the docs or the .github dirs, and then do not include any module in the list. -# But then we would need to verify the CI scripts to ensure that the job receives the correct modules to build. - -# ROOT_DIR is the root directory of the repository. -readonly ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd) - -# define an array of directories that won't be included in the list -readonly excluded_modules=(".devcontainer" ".vscode" ".husky" "docs" ".github/ISSUE_TEMPLATE") - -# define an array of files that won't be included in the list -# Get all files in the root directory except package.json and package-lock.json -# Create array of excluded files by finding all files in root dir except package.json and package-lock.json -excluded_files=("${ROOT_DIR}/.github/release-drafter.yml") -while IFS= read -r file; do - excluded_files+=("\"${file}\"") -done < <(find "${ROOT_DIR}" -maxdepth 1 -type f -not -name "package.json" -not -name "package-lock.json") - -# define an array of modules that won't be part of the build -readonly no_build_modules=() - -# modules is an array that will store the paths of all the modules in the repository. -modules=() - -# Find all package.json files in the repository, building a list of all the available modules. -# The list of modules is stored in the modules array, but the testcontainers-node module is excluded -# as it is not a module. -for packageJSONFile in $(find "${ROOT_DIR}" -name "package.json" -not -path "*/node_modules/*"); do - name=$(basename "$(dirname "${packageJSONFile}")") - if [[ "${name}" != "testcontainers-node" ]]; then - modules+=("\"${name}\"") - fi -done - -# sort modules array -IFS=$'\n' modules=($(sort <<<"${modules[*]}")) -unset IFS - -# Get the list of modified files, retrieved from the environment variable ALL_CHANGED_FILES. -# On CI, this value will come from a Github Action retrieving the list of modified files from the pull request. -readonly modified_files=${ALL_CHANGED_FILES[@]} - -# Initialize variables -modified_modules=() - -# Check the modified files and determine which modules to build, following these rules: -# - if the modified files contain any file in the root module, include all modules in the list -# - if the modified files only contain files in one of the modules, include that module in the list -for file in $modified_files; do - # check if the file is in one of the excluded files - for exclude_file in ${excluded_files[@]}; do - # Remove quotes from exclude_file for comparison - clean_exclude_file=$(echo $exclude_file | tr -d '"') - if [[ "${ROOT_DIR}/${file}" == "${clean_exclude_file}" ]]; then - # if the file is in the excluded files, skip the rest of the loop. - # Execution continues at the loop control of the 2nd enclosing loop. - continue 2 - fi - done - - if [[ $file == packages/modules/* ]]; then - module_name=$(echo $file | cut -d'/' -f3) - if [[ ! " ${modified_modules[@]} " =~ " ${module_name} " ]]; then - modified_modules+=("\"$module_name\"") - fi - else - # a file from the core module (packages/testcontainers) is modified, so include all modules in the list and stop the loop - # check if the file is in one of the excluded modules - for exclude_module in ${excluded_modules[@]}; do - if [[ $file == $exclude_module/* ]]; then - # continue skips to the next iteration of an enclosing for, select, until, or while loop in a shell script. - # Execution continues at the loop control of the nth enclosing loop, in this case two levels up. - continue 2 - fi - done - - modified_modules=${modules[@]} - break - fi -done - -# print all modules with this format: -# each module will be enclosed in double quotes -# each module will be separated by a comma -# the entire list will be enclosed in square brackets -# the list will be sorted and unique -sorted_unique_modules=($(echo "${modified_modules[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' ')) - -# remove modules that won't be part of the build from the list -filtered_modules=() -for module in "${sorted_unique_modules[@]}"; do - skip=false - for no_build_module in "${no_build_modules[@]}"; do - if [[ ${module} == \"${no_build_module}\" ]]; then - skip=true - break - fi - done - if [[ $skip == false ]]; then - filtered_modules+=(${module}) - fi -done -sorted_unique_modules=("${filtered_modules[@]}") - -echo "["$(IFS=,; echo "${sorted_unique_modules[*]}" | sed 's/ /,/g')"]" diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 2e4295e79..9ba7d96d2 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -23,29 +23,37 @@ jobs: name: Detect packages to check runs-on: ubuntu-22.04 outputs: - modules: ${{ steps.set-modified-modules.outputs.modules }} - modules_count: ${{ steps.set-modified-modules-count.outputs.modules_count }} + modules: ${{ steps.detect.outputs.modules }} + modules_count: ${{ steps.detect.outputs.modules_count }} + has_testcontainers: ${{ steps.detect.outputs.has_testcontainers }} steps: - name: Check out code uses: actions/checkout@v5 - - 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 + with: + fetch-depth: 0 + - id: detect + name: Detect changed packages 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 + BASE_SHA: ${{ github.event.pull_request.base.sha || github.event.before }} + HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }} run: | - echo "${{ steps.set-modified-modules-count.outputs.modules_count }} modules in the build" - echo "${{ steps.set-modified-modules.outputs.modules }}" + changed_files="${RUNNER_TEMP}/changed-files.txt" + + git diff --name-only "${BASE_SHA}" "${HEAD_SHA}" > "${changed_files}" + + modules="$(node ./.github/scripts/changed-modules.mjs < "${changed_files}")" + modules_count="$(jq 'length' <<< "${modules}")" + has_testcontainers="$(jq 'index("testcontainers") != null' <<< "${modules}")" + + echo "modules=${modules}" >> "${GITHUB_OUTPUT}" + echo "modules_count=${modules_count}" >> "${GITHUB_OUTPUT}" + echo "has_testcontainers=${has_testcontainers}" >> "${GITHUB_OUTPUT}" + + echo "${modules_count} packages in the build" + echo "${modules}" lint: - if: ${{ needs.detect-modules.outputs.modules_count > 0 }} + if: ${{ needs.detect-modules.outputs.modules_count != '0' }} name: "Lint" needs: - detect-modules @@ -70,7 +78,7 @@ jobs: run: npm run lint:ci compile: - if: ${{ needs.detect-modules.outputs.modules_count > 0 }} + if: ${{ needs.detect-modules.outputs.modules_count != '0' }} name: Compile needs: - detect-modules @@ -98,7 +106,7 @@ jobs: fi smoke-test: - if: ${{ needs.detect-modules.outputs.modules_count > 0 }} + if: ${{ needs.detect-modules.outputs.has_testcontainers == 'true' }} needs: - detect-modules - lint @@ -132,13 +140,12 @@ jobs: DEBUG: "testcontainers*" test: - if: ${{ needs.detect-modules.outputs.modules_count > 0 }} + if: ${{ needs.detect-modules.outputs.modules_count != '0' }} name: Tests needs: - detect-modules - lint - compile - - smoke-test strategy: fail-fast: false matrix: @@ -153,7 +160,7 @@ jobs: workspace: "${{ matrix.module }}" end: - if: ${{ needs.detect-modules.outputs.modules_count > 0 }} + if: ${{ always() && needs.detect-modules.outputs.modules_count != '0' }} name: Checks complete needs: - detect-modules @@ -164,6 +171,6 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Check if any jobs failed - if: ${{ failure() || cancelled() }} + if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }} run: exit 1 - run: echo "All tests completed successfully!" diff --git a/.github/workflows/test-template.yml b/.github/workflows/test-template.yml index 24eb7d676..27d19b92b 100644 --- a/.github/workflows/test-template.yml +++ b/.github/workflows/test-template.yml @@ -22,29 +22,10 @@ jobs: - name: Code checkout uses: actions/checkout@v5 - - name: Docker rootless setup - if: ${{ inputs.container-runtime == 'docker-rootless' }} - uses: ./.github/actions/docker-rootless-setup - - name: Podman setup if: ${{ inputs.container-runtime == 'podman' }} uses: ./.github/actions/podman-setup - - name: Colima setup - if: ${{ inputs.container-runtime == 'colima' }} - uses: ./.github/actions/colima-setup - with: - runner: ${{ inputs.runner }} - - - name: Rancher Desktop setup - if: ${{ inputs.container-runtime == 'rancher-desktop' }} - uses: ./.github/actions/rancher-desktop-setup - with: - runner: ${{ inputs.runner }} - - - name: Code checkout - uses: actions/checkout@v5 - - name: Install Node ${{ inputs.node-version }} and Dependencies id: npm-install uses: ./.github/actions/npm-setup diff --git a/.github/workflows/windows-test-command-dispatch.yml b/.github/workflows/windows-test-command-dispatch.yml deleted file mode 100644 index 89c742615..000000000 --- a/.github/workflows/windows-test-command-dispatch.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: windows-test command dispatch - -on: - issue_comment: - types: [created] - -jobs: - windows-test-command-dispatch: - runs-on: ubuntu-22.04 - - steps: - - name: Dispatch windows-test command - uses: peter-evans/slash-command-dispatch@v4 - with: - token: ${{ secrets.REPO_TOKEN }} - commands: windows-test - issue-type: pull-request - permission: maintain - reactions: false diff --git a/.github/workflows/windows-test.yml b/.github/workflows/windows-test.yml deleted file mode 100644 index ff4f0f861..000000000 --- a/.github/workflows/windows-test.yml +++ /dev/null @@ -1,79 +0,0 @@ -name: Test Windows - -on: - repository_dispatch: - types: [windows-test-command] - -jobs: - docker: - runs-on: [self-hosted, Windows, X64] - strategy: - fail-fast: false - steps: - - name: Create pending status - uses: actions/github-script@v7.0.1 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - async ({ github, context }) => { - await github.rest.repos.createCommitStatus({ - owner: context.repo.owner, - repo: context.repo.repo, - sha: context.payload.client_payload.pull_request.head.sha, - state: 'pending', - target_url: `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`, - context: 'Test Windows', - }); - } - - - name: Checkout - uses: actions/checkout@v5 - with: - token: ${{ secrets.GITHUB_TOKEN }} - repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }} - ref: ${{ github.event.client_payload.pull_request.head.ref }} - - - name: Install NodeJS - uses: actions/setup-node@v4 - with: - node-version: 24.x - - - name: Install dependencies - run: npm ci - - - name: Run tests - run: npm run test:ci - - - name: Create success status - uses: actions/github-script@v7.0.1 - if: success() - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - async ({ github, context }) => { - await github.rest.repos.createCommitStatus({ - owner: context.repo.owner, - repo: context.repo.repo, - sha: context.payload.client_payload.pull_request.head.sha, - state: 'success', - target_url: `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`, - context: 'Test Windows', - }); - } - - - name: Create failure status - uses: actions/github-script@v7.0.1 - if: failure() - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - async ({ github, context }) => { - await github.rest.repos.createCommitStatus({ - owner: context.repo.owner, - repo: context.repo.repo, - sha: context.payload.client_payload.pull_request.head.sha, - state: 'failure', - target_url: `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`, - context: 'Test Windows', - }); - } diff --git a/package.json b/package.json index 5a7bd4175..f6e1af29f 100644 --- a/package.json +++ b/package.json @@ -11,8 +11,8 @@ "docs:serve": "docker compose up", "test": "vitest run", "test:ci": "npm run test -- --coverage", - "format": "prettier --write package.json \"packages/**/*.ts\" \".github/**/*.yml\"", - "lint": "eslint --fix package.json \"packages/**/*.ts\"", + "format": "prettier --write package.json \"packages/**/*.ts\" \".github/**/*.yml\" \".github/**/*.mjs\"", + "lint": "eslint --fix package.json \"packages/**/*.ts\" \".github/**/*.mjs\"", "lint:ci": "eslint package.json \"${WORKSPACE_PATH}/**/*.ts\" --max-warnings=0", "update-deps": "npm-check-updates --workspaces --root -u", "check-compiles": "npm run build --ignore-scripts --ws -- --project tsconfig.json --noEmit" From f2c6eec7d554c982d27d02b898408108c9532a18 Mon Sep 17 00:00:00 2001 From: Cristian Greco Date: Fri, 15 May 2026 16:53:20 +0100 Subject: [PATCH 2/2] Update GitHub Actions versions --- .github/actions/npm-setup/action.yml | 16 ++++++++++++---- .github/workflows/checks.yml | 11 +++++++---- .github/workflows/codeql-analysis.yml | 8 ++++---- .github/workflows/dependency-review.yml | 4 ++-- .github/workflows/npm-publish.yml | 5 +++-- .github/workflows/release-drafter.yml | 6 +++++- .github/workflows/test-template.yml | 2 +- 7 files changed, 34 insertions(+), 18 deletions(-) diff --git a/.github/actions/npm-setup/action.yml b/.github/actions/npm-setup/action.yml index 20f8b6955..df34da377 100644 --- a/.github/actions/npm-setup/action.yml +++ b/.github/actions/npm-setup/action.yml @@ -41,18 +41,26 @@ runs: } >> "$GITHUB_OUTPUT" - name: Install NodeJS ${{ inputs.node-version }} - uses: actions/setup-node@v4 + uses: actions/setup-node@v6 with: node-version: ${{ inputs.node-version }} + package-manager-cache: false - - name: Cache dependencies - uses: actions/cache@v4 + - name: Restore dependencies cache + uses: actions/cache/restore@v4 id: npm-cache with: path: ${{ steps.set-workspace.outputs.cache_paths }} - key: ${{ inputs.runner }}-node-${{ inputs.node-version }}-${{ inputs.workspace }}-${{ hashFiles('package-lock.json') }} + key: npm-v2-${{ inputs.runner }}-node-${{ inputs.node-version }}-${{ inputs.workspace }}-${{ hashFiles('package-lock.json') }} - name: Install dependencies if: steps.npm-cache.outputs.cache-hit != 'true' shell: bash run: npm ci --workspace "${WORKSPACE_PATH}" --include-workspace-root + + - name: Save dependencies cache + if: steps.npm-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@v4 + with: + path: ${{ steps.set-workspace.outputs.cache_paths }} + key: ${{ steps.npm-cache.outputs.cache-primary-key }} diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 9ba7d96d2..7c19b2522 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -18,6 +18,9 @@ concurrency: group: "${{ github.workflow }}-${{ github.head_ref || github.sha }}" cancel-in-progress: true +permissions: + contents: read + jobs: detect-modules: name: Detect packages to check @@ -28,7 +31,7 @@ jobs: has_testcontainers: ${{ steps.detect.outputs.has_testcontainers }} steps: - name: Check out code - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: fetch-depth: 0 - id: detect @@ -64,7 +67,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Code checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 - name: Install Node and Dependencies id: npm-install-modules uses: ./.github/actions/npm-setup @@ -90,7 +93,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Code checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 - name: Install Node and Dependencies id: npm-install uses: ./.github/actions/npm-setup @@ -119,7 +122,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Code checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 - name: Install Node ${{ matrix.node-version }} and Dependencies uses: ./.github/actions/npm-setup with: diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 006b85433..df818104d 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -24,12 +24,12 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v5 + uses: actions/checkout@v6 - name: Initialize CodeQL - uses: github/codeql-action/init@v3 + uses: github/codeql-action/init@v4 with: languages: ${{ matrix.language }} - name: Autobuild - uses: github/codeql-action/autobuild@v3 + uses: github/codeql-action/autobuild@v4 - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v3 + uses: github/codeql-action/analyze@v4 diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml index 25ab4414a..7fa3e06b1 100644 --- a/.github/workflows/dependency-review.yml +++ b/.github/workflows/dependency-review.yml @@ -10,8 +10,8 @@ jobs: runs-on: ubuntu-22.04 steps: - name: "Checkout Repository" - uses: actions/checkout@v5 + uses: actions/checkout@v6 - name: "Dependency Review" - uses: actions/dependency-review-action@v4 + uses: actions/dependency-review-action@v5 with: fail-on-scopes: development diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index ed467a3c2..9994f6192 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -8,14 +8,15 @@ jobs: publish: runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 with: ref: main - - uses: actions/setup-node@v4 + - uses: actions/setup-node@v6 with: node-version: 22 registry-url: "https://registry.npmjs.org" + package-manager-cache: false - name: Configure Git run: | diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index b2a14c2ba..a38f24492 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -8,11 +8,15 @@ on: branches: - main +permissions: + contents: write + pull-requests: read + jobs: update_release_draft: runs-on: ubuntu-22.04 steps: # Drafts your next Release notes as Pull Requests are merged into "main" - - uses: release-drafter/release-drafter@v6 + - uses: release-drafter/release-drafter@v7 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test-template.yml b/.github/workflows/test-template.yml index 27d19b92b..8e90a34d1 100644 --- a/.github/workflows/test-template.yml +++ b/.github/workflows/test-template.yml @@ -20,7 +20,7 @@ jobs: runs-on: ${{ inputs.runner }} steps: - name: Code checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 - name: Podman setup if: ${{ inputs.container-runtime == 'podman' }}