Skip to content
Open
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
26 changes: 0 additions & 26 deletions .github/actions/colima-setup/action.yml

This file was deleted.

12 changes: 0 additions & 12 deletions .github/actions/docker-rootless-setup/action.yml

This file was deleted.

57 changes: 29 additions & 28 deletions .github/actions/npm-setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,57 +9,58 @@ 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<<EOF" >> $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<<EOF" >> $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<<EOF"
echo "${cache_paths}"
echo "EOF"
} >> "$GITHUB_OUTPUT"

- name: Install NodeJS ${{ inputs.node-version }}
uses: actions/setup-node@v6
with:
node-version: ${{ inputs.node-version }}
package-manager-cache: false

- name: Restore dependencies cache
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') }}
path: ${{ steps.set-workspace.outputs.cache_paths }}
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 ${{ env.WORKSPACE_PATH }} --include-workspace-root
run: npm ci --workspace "${WORKSPACE_PATH}" --include-workspace-root

- name: Cache npm
- name: Save dependencies cache
if: steps.npm-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: ${{ env.CACHE_PATHS }}
path: ${{ steps.set-workspace.outputs.cache_paths }}
key: ${{ steps.npm-cache.outputs.cache-primary-key }}
77 changes: 0 additions & 77 deletions .github/actions/rancher-desktop-setup/action.yml

This file was deleted.

65 changes: 65 additions & 0 deletions .github/scripts/changed-modules.mjs
Original file line number Diff line number Diff line change
@@ -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`);
Loading
Loading