From 16e35d78c3c4e1f787bd068c2b7e39088225e6f7 Mon Sep 17 00:00:00 2001 From: Christian Fehmer Date: Mon, 15 Sep 2025 22:35:20 +0200 Subject: [PATCH 1/8] ci: cache testcontainers between runs (@fehmer) --- .github/workflows/monkey-ci.yml | 17 +++++++++++++++++ .../__tests__/__integration__/global-setup.ts | 2 ++ 2 files changed, 19 insertions(+) diff --git a/.github/workflows/monkey-ci.yml b/.github/workflows/monkey-ci.yml index 21252fdf4120..46129e209807 100644 --- a/.github/workflows/monkey-ci.yml +++ b/.github/workflows/monkey-ci.yml @@ -126,6 +126,9 @@ jobs: needs: [pre-ci, prime-cache] runs-on: ubuntu-latest if: needs.pre-ci.outputs.should-build-be == 'true' || needs.pre-ci.outputs.should-build-pkg == 'true' || contains(github.event.pull_request.labels.*.name, 'force-full-ci') + env: + TESTCONTAINERS_TYUK_DISABLED: true #don't remove docker images after testcontainers shuts down + TESTCONTAINERS_TMPDIR: tmp/.testcontainers steps: - uses: actions/checkout@v4 with: @@ -160,6 +163,20 @@ jobs: - name: Install dependencies run: pnpm install + - name: Cache testcontainers tmpdir + id: cache-testcontainers + uses: actions/cache@v4 + env: + cache-name: testcontainers + with: + path: tmp/.testcontainers + key: ${{ runner.os }}-testcontainers-mongo-5.0.13-redis-6.2.6 + + - name: Pull testcontainers images + run: | + docker pull mongo:5.0.13 + docker pull redis:6.2.6 + - name: Check lint run: npm run lint-be diff --git a/backend/__tests__/__integration__/global-setup.ts b/backend/__tests__/__integration__/global-setup.ts index 75a4f2865c07..d6f1f30f8f9c 100644 --- a/backend/__tests__/__integration__/global-setup.ts +++ b/backend/__tests__/__integration__/global-setup.ts @@ -7,6 +7,7 @@ export async function setup(): Promise { process.env.TZ = "UTC"; //use testcontainer to start mongodb + //make sure to update the image version in monkey-ci.yml if you change it here const mongoContainer = new GenericContainer("mongo:5.0.13") .withExposedPorts(27017) .withWaitStrategy(Wait.forListeningPorts()); @@ -19,6 +20,7 @@ export async function setup(): Promise { process.env["TEST_DB_URL"] = mongoUrl; //use testcontainer to start redis + //make sure to update the image version in monkey-ci.yml if you change it here const redisContainer = new GenericContainer("redis:6.2.6") .withExposedPorts(6379) .withWaitStrategy(Wait.forLogMessage("Ready to accept connections")); From a64636e6f3582b1b3fbdea207796793069aa88de Mon Sep 17 00:00:00 2001 From: Christian Fehmer Date: Mon, 15 Sep 2025 22:38:57 +0200 Subject: [PATCH 2/8] trigger From 838cc37fa431476f83aad2f14037bd1f5ae191fa Mon Sep 17 00:00:00 2001 From: Christian Fehmer Date: Mon, 15 Sep 2025 22:42:37 +0200 Subject: [PATCH 3/8] path --- .github/workflows/monkey-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/monkey-ci.yml b/.github/workflows/monkey-ci.yml index 46129e209807..046be5380e26 100644 --- a/.github/workflows/monkey-ci.yml +++ b/.github/workflows/monkey-ci.yml @@ -169,7 +169,7 @@ jobs: env: cache-name: testcontainers with: - path: tmp/.testcontainers + path: /var/lib/docker key: ${{ runner.os }}-testcontainers-mongo-5.0.13-redis-6.2.6 - name: Pull testcontainers images From 90bc5cc285e22f557937398080fa9108b42abb00 Mon Sep 17 00:00:00 2001 From: Christian Fehmer Date: Mon, 15 Sep 2025 22:48:21 +0200 Subject: [PATCH 4/8] use custom tmpdir --- .github/workflows/monkey-ci.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/monkey-ci.yml b/.github/workflows/monkey-ci.yml index 046be5380e26..bcbd0b1a05dc 100644 --- a/.github/workflows/monkey-ci.yml +++ b/.github/workflows/monkey-ci.yml @@ -163,13 +163,15 @@ jobs: - name: Install dependencies run: pnpm install + - name: Ensure testcontainers tempdir exists + run: mkdir -p tmp/.testcontainers + - name: Cache testcontainers tmpdir id: cache-testcontainers uses: actions/cache@v4 - env: - cache-name: testcontainers + with: - path: /var/lib/docker + path: tmp/.testcontainers key: ${{ runner.os }}-testcontainers-mongo-5.0.13-redis-6.2.6 - name: Pull testcontainers images @@ -177,6 +179,11 @@ jobs: docker pull mongo:5.0.13 docker pull redis:6.2.6 + - name: Preload images into testcontainers tempdir + run: | + docker run --rm -v $PWD/tmp/.testcontainers:/tmp mongo:5.0.13 true + docker run --rm -v $PWD/tmp/.testcontainers:/tmp redis:6.2.6 true + - name: Check lint run: npm run lint-be From 99ddadc956e1a4f85abf1a8a37aadb2c62295775 Mon Sep 17 00:00:00 2001 From: Christian Fehmer Date: Mon, 15 Sep 2025 22:58:35 +0200 Subject: [PATCH 5/8] prebuild action --- .github/workflows/monkey-ci.yml | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/.github/workflows/monkey-ci.yml b/.github/workflows/monkey-ci.yml index bcbd0b1a05dc..a4f9f4dd4709 100644 --- a/.github/workflows/monkey-ci.yml +++ b/.github/workflows/monkey-ci.yml @@ -126,9 +126,6 @@ jobs: needs: [pre-ci, prime-cache] runs-on: ubuntu-latest if: needs.pre-ci.outputs.should-build-be == 'true' || needs.pre-ci.outputs.should-build-pkg == 'true' || contains(github.event.pull_request.labels.*.name, 'force-full-ci') - env: - TESTCONTAINERS_TYUK_DISABLED: true #don't remove docker images after testcontainers shuts down - TESTCONTAINERS_TMPDIR: tmp/.testcontainers steps: - uses: actions/checkout@v4 with: @@ -163,27 +160,17 @@ jobs: - name: Install dependencies run: pnpm install - - name: Ensure testcontainers tempdir exists - run: mkdir -p tmp/.testcontainers - - name: Cache testcontainers tmpdir id: cache-testcontainers - uses: actions/cache@v4 - + uses: ScribeMD/docker-cache@0.5.0 with: - path: tmp/.testcontainers key: ${{ runner.os }}-testcontainers-mongo-5.0.13-redis-6.2.6 - name: Pull testcontainers images run: | docker pull mongo:5.0.13 docker pull redis:6.2.6 - - - name: Preload images into testcontainers tempdir - run: | - docker run --rm -v $PWD/tmp/.testcontainers:/tmp mongo:5.0.13 true - docker run --rm -v $PWD/tmp/.testcontainers:/tmp redis:6.2.6 true - + - name: Check lint run: npm run lint-be From 7f02698ff46dd79ff5fe98ef3630de672df6015c Mon Sep 17 00:00:00 2001 From: Christian Fehmer Date: Mon, 15 Sep 2025 23:03:42 +0200 Subject: [PATCH 6/8] trigger --- .github/workflows/monkey-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/monkey-ci.yml b/.github/workflows/monkey-ci.yml index a4f9f4dd4709..97faa11b57a6 100644 --- a/.github/workflows/monkey-ci.yml +++ b/.github/workflows/monkey-ci.yml @@ -160,7 +160,7 @@ jobs: - name: Install dependencies run: pnpm install - - name: Cache testcontainers tmpdir + - name: Cache testcontainers images id: cache-testcontainers uses: ScribeMD/docker-cache@0.5.0 with: From b84f9938d97ee7970158a518e0eb7036bb899d34 Mon Sep 17 00:00:00 2001 From: Christian Fehmer Date: Mon, 15 Sep 2025 23:10:20 +0200 Subject: [PATCH 7/8] modern action --- .github/workflows/monkey-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/monkey-ci.yml b/.github/workflows/monkey-ci.yml index 97faa11b57a6..0d97fb981468 100644 --- a/.github/workflows/monkey-ci.yml +++ b/.github/workflows/monkey-ci.yml @@ -162,7 +162,7 @@ jobs: - name: Cache testcontainers images id: cache-testcontainers - uses: ScribeMD/docker-cache@0.5.0 + uses: AndreKurait/docker-cache@0.6.0 with: key: ${{ runner.os }}-testcontainers-mongo-5.0.13-redis-6.2.6 From 06d8fcaacfefe3c86d5a387bfe01621eccc8d324 Mon Sep 17 00:00:00 2001 From: Christian Fehmer Date: Mon, 15 Sep 2025 23:13:02 +0200 Subject: [PATCH 8/8] trigger