From 99ecf4c94d127c469b63ce0fd2b0978c016067ca Mon Sep 17 00:00:00 2001 From: nicholas-codecov Date: Tue, 5 Dec 2023 12:11:21 -0400 Subject: [PATCH 01/17] fix up integration test and add initial rollup stats test --- .../generateRollupStats.test.ts | 95 +++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 integration-tests/fixtures/generate-bundle-stats/generateRollupStats.test.ts diff --git a/integration-tests/fixtures/generate-bundle-stats/generateRollupStats.test.ts b/integration-tests/fixtures/generate-bundle-stats/generateRollupStats.test.ts new file mode 100644 index 00000000..bb7dccfc --- /dev/null +++ b/integration-tests/fixtures/generate-bundle-stats/generateRollupStats.test.ts @@ -0,0 +1,95 @@ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ +import path from "path"; +import fs from "fs"; +import { spawnSync } from "child_process"; +import { type Output } from "@codecov/bundler-plugin-core"; + +const expectedStats = { + version: "1", + plugin: { name: "codecov-rollup-bundle-analysis-plugin", version: "1.0.0" }, + builtAt: 1701788687217, + duration: 7, + bundler: { name: "rollup", version: "4.6.1" }, + assets: [{ name: "main-Kc6Ge1DG.js", size: 216 }], + chunks: [ + { + id: "main", + uniqueId: "0-main", + entry: true, + initial: false, + files: ["main-Kc6Ge1DG.js"], + names: ["main"], + }, + ], + modules: [ + { + name: "./src/getRandomNumber.js", + size: 98, + chunks: ["main"], + chunkUniqueIds: ["0-main"], + }, + { + name: "./src/main.js", + size: 115, + chunks: ["main"], + chunkUniqueIds: ["0-main"], + }, + ], +}; + +describe("Generating rollup stats", () => { + let stats: Output; + beforeAll(() => { + const rollupPath = path.resolve(__dirname, "../../test-apps/rollup"); + + spawnSync("pnpm", ["run", "build"], { + cwd: rollupPath, + }); + + const statsFilePath = path.resolve( + rollupPath, + "dist/codecov-bundle-stats.json", + ); + + const statsData = fs.readFileSync(statsFilePath); + stats = JSON.parse(statsData.toString()) as Output; + }); + + it("sets the correct version", () => { + expect(stats.version).toStrictEqual(expectedStats.version); + }); + + it("sets the correct plugin information", () => { + expect(stats.plugin).toStrictEqual(expectedStats.plugin); + }); + + it("sets the correct bundler information", () => { + expect(stats.bundler).toStrictEqual(expectedStats.bundler); + }); + + it("sets the correct assets information", () => { + const asset = stats?.assets?.[0]; + expect(asset?.name).toBe(expectedStats?.assets?.[0]?.name); + expect(asset?.size).toBe(expectedStats?.assets?.[0]?.size); + }); + + it("sets the correct chunks information", () => { + const chunk = stats?.chunks?.[0]; + expect(chunk?.id).toBe(expectedStats?.chunks?.[0]?.id); + expect(chunk?.initial).toBe(expectedStats?.chunks?.[0]?.initial); + expect(chunk?.entry).toBe(expectedStats?.chunks?.[0]?.entry); + expect(chunk?.names).toStrictEqual(expectedStats?.chunks?.[0]?.names); + expect(chunk?.files).toStrictEqual(expectedStats?.chunks?.[0]?.files); + }); + + it("sets the correct modules information", () => { + const module = stats?.modules?.[0]; + expect(module?.name).toBe(expectedStats?.modules?.[0]?.name); + expect(module?.size).toBe(expectedStats?.modules?.[0]?.size); + expect(module?.chunks).toStrictEqual(expectedStats?.modules?.[0]?.chunks); + expect(module?.chunkUniqueIds).toStrictEqual( + expectedStats?.modules?.[0]?.chunkUniqueIds, + ); + }); +}); From fea569b9a13902aacca7919106b8d36e9db20991 Mon Sep 17 00:00:00 2001 From: nicholas-codecov Date: Tue, 5 Dec 2023 13:03:37 -0400 Subject: [PATCH 02/17] actually set bundler information --- .../src/webpack-bundle-analysis/webpackBundleAnalysisPlugin.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/webpack-plugin/src/webpack-bundle-analysis/webpackBundleAnalysisPlugin.ts b/packages/webpack-plugin/src/webpack-bundle-analysis/webpackBundleAnalysisPlugin.ts index f529f8ca..cf177141 100644 --- a/packages/webpack-plugin/src/webpack-bundle-analysis/webpackBundleAnalysisPlugin.ts +++ b/packages/webpack-plugin/src/webpack-bundle-analysis/webpackBundleAnalysisPlugin.ts @@ -85,6 +85,8 @@ export const webpackBundleAnalysisPlugin: BundleAnalysisUploadPlugin = ({ }); } + console.info("webpackBundleAnalysisPlugin output", output); + // only output file if running dry run if (userOptions?.dryRun) { const { RawSource } = webpack4or5.sources; From 7151ef203689b16b9ef5bea68c7af53f2d2fef2a Mon Sep 17 00:00:00 2001 From: nicholas-codecov Date: Tue, 5 Dec 2023 13:04:04 -0400 Subject: [PATCH 03/17] get very very basic e2e up and running --- ...rateRollupStats.test.ts => rollup.test.ts} | 36 +++------ .../generate-bundle-stats/vite.test.ts | 77 +++++++++++++++++++ .../generate-bundle-stats/webpack.test.ts | 77 +++++++++++++++++++ 3 files changed, 163 insertions(+), 27 deletions(-) rename integration-tests/fixtures/generate-bundle-stats/{generateRollupStats.test.ts => rollup.test.ts} (60%) create mode 100644 integration-tests/fixtures/generate-bundle-stats/vite.test.ts create mode 100644 integration-tests/fixtures/generate-bundle-stats/webpack.test.ts diff --git a/integration-tests/fixtures/generate-bundle-stats/generateRollupStats.test.ts b/integration-tests/fixtures/generate-bundle-stats/rollup.test.ts similarity index 60% rename from integration-tests/fixtures/generate-bundle-stats/generateRollupStats.test.ts rename to integration-tests/fixtures/generate-bundle-stats/rollup.test.ts index bb7dccfc..16830758 100644 --- a/integration-tests/fixtures/generate-bundle-stats/generateRollupStats.test.ts +++ b/integration-tests/fixtures/generate-bundle-stats/rollup.test.ts @@ -40,9 +40,8 @@ const expectedStats = { describe("Generating rollup stats", () => { let stats: Output; + const rollupPath = path.resolve(__dirname, "../../test-apps/rollup"); beforeAll(() => { - const rollupPath = path.resolve(__dirname, "../../test-apps/rollup"); - spawnSync("pnpm", ["run", "build"], { cwd: rollupPath, }); @@ -56,6 +55,14 @@ describe("Generating rollup stats", () => { stats = JSON.parse(statsData.toString()) as Output; }); + afterAll(() => { + fs.rm( + path.resolve(rollupPath, "dist"), + { recursive: true, force: true }, + () => null, + ); + }); + it("sets the correct version", () => { expect(stats.version).toStrictEqual(expectedStats.version); }); @@ -67,29 +74,4 @@ describe("Generating rollup stats", () => { it("sets the correct bundler information", () => { expect(stats.bundler).toStrictEqual(expectedStats.bundler); }); - - it("sets the correct assets information", () => { - const asset = stats?.assets?.[0]; - expect(asset?.name).toBe(expectedStats?.assets?.[0]?.name); - expect(asset?.size).toBe(expectedStats?.assets?.[0]?.size); - }); - - it("sets the correct chunks information", () => { - const chunk = stats?.chunks?.[0]; - expect(chunk?.id).toBe(expectedStats?.chunks?.[0]?.id); - expect(chunk?.initial).toBe(expectedStats?.chunks?.[0]?.initial); - expect(chunk?.entry).toBe(expectedStats?.chunks?.[0]?.entry); - expect(chunk?.names).toStrictEqual(expectedStats?.chunks?.[0]?.names); - expect(chunk?.files).toStrictEqual(expectedStats?.chunks?.[0]?.files); - }); - - it("sets the correct modules information", () => { - const module = stats?.modules?.[0]; - expect(module?.name).toBe(expectedStats?.modules?.[0]?.name); - expect(module?.size).toBe(expectedStats?.modules?.[0]?.size); - expect(module?.chunks).toStrictEqual(expectedStats?.modules?.[0]?.chunks); - expect(module?.chunkUniqueIds).toStrictEqual( - expectedStats?.modules?.[0]?.chunkUniqueIds, - ); - }); }); diff --git a/integration-tests/fixtures/generate-bundle-stats/vite.test.ts b/integration-tests/fixtures/generate-bundle-stats/vite.test.ts new file mode 100644 index 00000000..300538a1 --- /dev/null +++ b/integration-tests/fixtures/generate-bundle-stats/vite.test.ts @@ -0,0 +1,77 @@ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ +import path from "path"; +import fs from "fs"; +import { spawnSync } from "child_process"; +import { type Output } from "@codecov/bundler-plugin-core"; + +const expectedStats = { + version: "1", + plugin: { name: "codecov-vite-bundle-analysis-plugin", version: "1.0.0" }, + builtAt: 1701788687217, + duration: 7, + bundler: { name: "rollup", version: "4.6.1" }, + assets: [{ name: "main-Kc6Ge1DG.js", size: 216 }], + chunks: [ + { + id: "main", + uniqueId: "0-main", + entry: true, + initial: false, + files: ["main-Kc6Ge1DG.js"], + names: ["main"], + }, + ], + modules: [ + { + name: "./src/getRandomNumber.js", + size: 98, + chunks: ["main"], + chunkUniqueIds: ["0-main"], + }, + { + name: "./src/main.js", + size: 115, + chunks: ["main"], + chunkUniqueIds: ["0-main"], + }, + ], +}; + +describe("Generating vite stats", () => { + let stats: Output; + const vitePath = path.resolve(__dirname, "../../test-apps/vite"); + beforeAll(() => { + spawnSync("pnpm", ["run", "build"], { + cwd: vitePath, + }); + + const statsFilePath = path.resolve( + vitePath, + "dist/codecov-bundle-stats.json", + ); + + const statsData = fs.readFileSync(statsFilePath); + stats = JSON.parse(statsData.toString()) as Output; + }); + + afterAll(() => { + fs.rm( + path.resolve(vitePath, "dist"), + { recursive: true, force: true }, + () => null, + ); + }); + + it("sets the correct version", () => { + expect(stats.version).toStrictEqual(expectedStats.version); + }); + + it("sets the correct plugin information", () => { + expect(stats.plugin).toStrictEqual(expectedStats.plugin); + }); + + it("sets the correct bundler information", () => { + expect(stats.bundler).toStrictEqual(expectedStats.bundler); + }); +}); diff --git a/integration-tests/fixtures/generate-bundle-stats/webpack.test.ts b/integration-tests/fixtures/generate-bundle-stats/webpack.test.ts new file mode 100644 index 00000000..a9816036 --- /dev/null +++ b/integration-tests/fixtures/generate-bundle-stats/webpack.test.ts @@ -0,0 +1,77 @@ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ +import path from "path"; +import fs from "fs"; +import { spawnSync } from "child_process"; +import { type Output } from "@codecov/bundler-plugin-core"; + +const expectedStats = { + version: "1", + plugin: { name: "codecov-webpack-bundle-analysis-plugin", version: "1.0.0" }, + builtAt: 1701788687217, + duration: 7, + bundler: { name: "webpack", version: "5.89.0" }, + assets: [{ name: "main-Kc6Ge1DG.js", size: 216 }], + chunks: [ + { + id: "main", + uniqueId: "0-main", + entry: true, + initial: false, + files: ["main-Kc6Ge1DG.js"], + names: ["main"], + }, + ], + modules: [ + { + name: "./src/getRandomNumber.js", + size: 98, + chunks: ["main"], + chunkUniqueIds: ["0-main"], + }, + { + name: "./src/main.js", + size: 115, + chunks: ["main"], + chunkUniqueIds: ["0-main"], + }, + ], +}; + +describe("Generating webpack stats", () => { + let stats: Output; + const webpackPath = path.resolve(__dirname, "../../test-apps/webpack"); + beforeAll(() => { + spawnSync("pnpm", ["run", "build"], { + cwd: webpackPath, + }); + + const statsFilePath = path.resolve( + webpackPath, + "dist/codecov-bundle-stats.json", + ); + + const statsData = fs.readFileSync(statsFilePath); + stats = JSON.parse(statsData.toString()) as Output; + }); + + afterAll(() => { + fs.rm( + path.resolve(webpackPath, "dist"), + { recursive: true, force: true }, + () => null, + ); + }); + + it("sets the correct version", () => { + expect(stats.version).toStrictEqual(expectedStats.version); + }); + + it("sets the correct plugin information", () => { + expect(stats.plugin).toStrictEqual(expectedStats.plugin); + }); + + it("sets the correct bundler information", () => { + expect(stats.bundler).toStrictEqual(expectedStats.bundler); + }); +}); From 7bad17e9490b0ed52ff4381c4535c759fe3aa253 Mon Sep 17 00:00:00 2001 From: nicholas-codecov Date: Wed, 6 Dec 2023 09:42:31 -0400 Subject: [PATCH 04/17] only run CI when pushing packages or integration test dirs --- .github/workflows/ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1e706545..e86e0273 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,7 +5,13 @@ on: branches: - main - staging + paths: + - "packages/**" + - "integration-tests/**" pull_request: + paths: + - "packages/**" + - "integration-tests/**" concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} From e5b0670700fa44dbef05975d48577c43b6377c11 Mon Sep 17 00:00:00 2001 From: nicholas-codecov Date: Wed, 6 Dec 2023 09:48:56 -0400 Subject: [PATCH 05/17] rename and move to programatically creating bundles --- .../generate-bundle-stats/rollup.test.ts | 77 ------------------- .../generate-bundle-stats/vite.test.ts | 77 ------------------- .../generate-bundle-stats/webpack.test.ts | 77 ------------------- 3 files changed, 231 deletions(-) delete mode 100644 integration-tests/fixtures/generate-bundle-stats/rollup.test.ts delete mode 100644 integration-tests/fixtures/generate-bundle-stats/vite.test.ts delete mode 100644 integration-tests/fixtures/generate-bundle-stats/webpack.test.ts diff --git a/integration-tests/fixtures/generate-bundle-stats/rollup.test.ts b/integration-tests/fixtures/generate-bundle-stats/rollup.test.ts deleted file mode 100644 index 16830758..00000000 --- a/integration-tests/fixtures/generate-bundle-stats/rollup.test.ts +++ /dev/null @@ -1,77 +0,0 @@ -/* eslint-disable @typescript-eslint/no-unsafe-assignment */ -/* eslint-disable @typescript-eslint/no-unsafe-member-access */ -import path from "path"; -import fs from "fs"; -import { spawnSync } from "child_process"; -import { type Output } from "@codecov/bundler-plugin-core"; - -const expectedStats = { - version: "1", - plugin: { name: "codecov-rollup-bundle-analysis-plugin", version: "1.0.0" }, - builtAt: 1701788687217, - duration: 7, - bundler: { name: "rollup", version: "4.6.1" }, - assets: [{ name: "main-Kc6Ge1DG.js", size: 216 }], - chunks: [ - { - id: "main", - uniqueId: "0-main", - entry: true, - initial: false, - files: ["main-Kc6Ge1DG.js"], - names: ["main"], - }, - ], - modules: [ - { - name: "./src/getRandomNumber.js", - size: 98, - chunks: ["main"], - chunkUniqueIds: ["0-main"], - }, - { - name: "./src/main.js", - size: 115, - chunks: ["main"], - chunkUniqueIds: ["0-main"], - }, - ], -}; - -describe("Generating rollup stats", () => { - let stats: Output; - const rollupPath = path.resolve(__dirname, "../../test-apps/rollup"); - beforeAll(() => { - spawnSync("pnpm", ["run", "build"], { - cwd: rollupPath, - }); - - const statsFilePath = path.resolve( - rollupPath, - "dist/codecov-bundle-stats.json", - ); - - const statsData = fs.readFileSync(statsFilePath); - stats = JSON.parse(statsData.toString()) as Output; - }); - - afterAll(() => { - fs.rm( - path.resolve(rollupPath, "dist"), - { recursive: true, force: true }, - () => null, - ); - }); - - it("sets the correct version", () => { - expect(stats.version).toStrictEqual(expectedStats.version); - }); - - it("sets the correct plugin information", () => { - expect(stats.plugin).toStrictEqual(expectedStats.plugin); - }); - - it("sets the correct bundler information", () => { - expect(stats.bundler).toStrictEqual(expectedStats.bundler); - }); -}); diff --git a/integration-tests/fixtures/generate-bundle-stats/vite.test.ts b/integration-tests/fixtures/generate-bundle-stats/vite.test.ts deleted file mode 100644 index 300538a1..00000000 --- a/integration-tests/fixtures/generate-bundle-stats/vite.test.ts +++ /dev/null @@ -1,77 +0,0 @@ -/* eslint-disable @typescript-eslint/no-unsafe-assignment */ -/* eslint-disable @typescript-eslint/no-unsafe-member-access */ -import path from "path"; -import fs from "fs"; -import { spawnSync } from "child_process"; -import { type Output } from "@codecov/bundler-plugin-core"; - -const expectedStats = { - version: "1", - plugin: { name: "codecov-vite-bundle-analysis-plugin", version: "1.0.0" }, - builtAt: 1701788687217, - duration: 7, - bundler: { name: "rollup", version: "4.6.1" }, - assets: [{ name: "main-Kc6Ge1DG.js", size: 216 }], - chunks: [ - { - id: "main", - uniqueId: "0-main", - entry: true, - initial: false, - files: ["main-Kc6Ge1DG.js"], - names: ["main"], - }, - ], - modules: [ - { - name: "./src/getRandomNumber.js", - size: 98, - chunks: ["main"], - chunkUniqueIds: ["0-main"], - }, - { - name: "./src/main.js", - size: 115, - chunks: ["main"], - chunkUniqueIds: ["0-main"], - }, - ], -}; - -describe("Generating vite stats", () => { - let stats: Output; - const vitePath = path.resolve(__dirname, "../../test-apps/vite"); - beforeAll(() => { - spawnSync("pnpm", ["run", "build"], { - cwd: vitePath, - }); - - const statsFilePath = path.resolve( - vitePath, - "dist/codecov-bundle-stats.json", - ); - - const statsData = fs.readFileSync(statsFilePath); - stats = JSON.parse(statsData.toString()) as Output; - }); - - afterAll(() => { - fs.rm( - path.resolve(vitePath, "dist"), - { recursive: true, force: true }, - () => null, - ); - }); - - it("sets the correct version", () => { - expect(stats.version).toStrictEqual(expectedStats.version); - }); - - it("sets the correct plugin information", () => { - expect(stats.plugin).toStrictEqual(expectedStats.plugin); - }); - - it("sets the correct bundler information", () => { - expect(stats.bundler).toStrictEqual(expectedStats.bundler); - }); -}); diff --git a/integration-tests/fixtures/generate-bundle-stats/webpack.test.ts b/integration-tests/fixtures/generate-bundle-stats/webpack.test.ts deleted file mode 100644 index a9816036..00000000 --- a/integration-tests/fixtures/generate-bundle-stats/webpack.test.ts +++ /dev/null @@ -1,77 +0,0 @@ -/* eslint-disable @typescript-eslint/no-unsafe-assignment */ -/* eslint-disable @typescript-eslint/no-unsafe-member-access */ -import path from "path"; -import fs from "fs"; -import { spawnSync } from "child_process"; -import { type Output } from "@codecov/bundler-plugin-core"; - -const expectedStats = { - version: "1", - plugin: { name: "codecov-webpack-bundle-analysis-plugin", version: "1.0.0" }, - builtAt: 1701788687217, - duration: 7, - bundler: { name: "webpack", version: "5.89.0" }, - assets: [{ name: "main-Kc6Ge1DG.js", size: 216 }], - chunks: [ - { - id: "main", - uniqueId: "0-main", - entry: true, - initial: false, - files: ["main-Kc6Ge1DG.js"], - names: ["main"], - }, - ], - modules: [ - { - name: "./src/getRandomNumber.js", - size: 98, - chunks: ["main"], - chunkUniqueIds: ["0-main"], - }, - { - name: "./src/main.js", - size: 115, - chunks: ["main"], - chunkUniqueIds: ["0-main"], - }, - ], -}; - -describe("Generating webpack stats", () => { - let stats: Output; - const webpackPath = path.resolve(__dirname, "../../test-apps/webpack"); - beforeAll(() => { - spawnSync("pnpm", ["run", "build"], { - cwd: webpackPath, - }); - - const statsFilePath = path.resolve( - webpackPath, - "dist/codecov-bundle-stats.json", - ); - - const statsData = fs.readFileSync(statsFilePath); - stats = JSON.parse(statsData.toString()) as Output; - }); - - afterAll(() => { - fs.rm( - path.resolve(webpackPath, "dist"), - { recursive: true, force: true }, - () => null, - ); - }); - - it("sets the correct version", () => { - expect(stats.version).toStrictEqual(expectedStats.version); - }); - - it("sets the correct plugin information", () => { - expect(stats.plugin).toStrictEqual(expectedStats.plugin); - }); - - it("sets the correct bundler information", () => { - expect(stats.bundler).toStrictEqual(expectedStats.bundler); - }); -}); From 9f0d877b2681fdc0dc8827e85a1eda4db9c97d29 Mon Sep 17 00:00:00 2001 From: nicholas-codecov Date: Wed, 6 Dec 2023 10:08:07 -0400 Subject: [PATCH 06/17] remove left over console.infos --- .../src/webpack-bundle-analysis/webpackBundleAnalysisPlugin.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/webpack-plugin/src/webpack-bundle-analysis/webpackBundleAnalysisPlugin.ts b/packages/webpack-plugin/src/webpack-bundle-analysis/webpackBundleAnalysisPlugin.ts index cf177141..f529f8ca 100644 --- a/packages/webpack-plugin/src/webpack-bundle-analysis/webpackBundleAnalysisPlugin.ts +++ b/packages/webpack-plugin/src/webpack-bundle-analysis/webpackBundleAnalysisPlugin.ts @@ -85,8 +85,6 @@ export const webpackBundleAnalysisPlugin: BundleAnalysisUploadPlugin = ({ }); } - console.info("webpackBundleAnalysisPlugin output", output); - // only output file if running dry run if (userOptions?.dryRun) { const { RawSource } = webpack4or5.sources; From 4c1d56bcf39bfeb30da6a43f7c0d5cbbabd99bb3 Mon Sep 17 00:00:00 2001 From: nicholas-codecov Date: Fri, 8 Dec 2023 07:21:42 -0400 Subject: [PATCH 07/17] because we're running codecov we should probably always run CI --- .github/workflows/ci.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e86e0273..1e706545 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,13 +5,7 @@ on: branches: - main - staging - paths: - - "packages/**" - - "integration-tests/**" pull_request: - paths: - - "packages/**" - - "integration-tests/**" concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} From 2090e639dbc08bab1441c7f9387515b8173b0676 Mon Sep 17 00:00:00 2001 From: trent-codecov Date: Sat, 9 Dec 2023 13:17:57 -0500 Subject: [PATCH 08/17] Adding test api ci --- .github/workflows/test-api-ci.yml | 36 +++++++++++++++++++++++++++++++ Makefile | 23 ++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 .github/workflows/test-api-ci.yml create mode 100644 Makefile diff --git a/.github/workflows/test-api-ci.yml b/.github/workflows/test-api-ci.yml new file mode 100644 index 00000000..121887b5 --- /dev/null +++ b/.github/workflows/test-api-ci.yml @@ -0,0 +1,36 @@ +name: CI + +on: + push: + branches: + - main +# paths: +# - integration-tests/test-api/** + pull_request: +# paths: +# - integration-tests/test-api/** + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + + +jobs: + build: + name: Build API Test + if: github.event_name != 'push' + uses: codecov/gha-workflows/.github/workflows/build-and-push-dockerhub.yml@trent/build-push-dockerhub + secrets: inherit + with: + push: false + image_name: test-api + docker_path: integration-tests/test-api/Dockerfile + push: + name: Build API Test + if: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/main' && github.repository_owner == 'codecov' }} + uses: codecov/gha-workflows/.github/workflows/build-and-push-dockerhub.yml@trent/build-push-dockerhub + secrets: inherit + with: + push: true + image_name: test-api + docker_path: integration-tests/test-api/Dockerfile diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..178cd508 --- /dev/null +++ b/Makefile @@ -0,0 +1,23 @@ +DOCKERHUB_REPO ?= codecov +IMAGE_NAME ?= test-api +DOCKER_PATH ?= integration-tests/test-api/Dockerfile + +dockerhub_image := ${DOCKERHUB_REPO}/${IMAGE_NAME} +export DOCKER_BUILDKIT := 1 + +build.${IMAGE_NAME}: + docker build -f ${DOCKER_PATH} . -t ${dockerhub_image}:latest \ + -t ${dockerhub_image}:${sha} \ + --label "org.label-schema.build-date"="$(build_date)" \ + --label "org.label-schema.name"="${IMAGE_NAME}" \ + --label "org.label-schema.vendor"="Codecov" \ + --label "org.label-schema.version"="${release_version}-${sha}" + +tag.${IMAGE_NAME}: + docker tag ${dockerhub_image}:${sha} ${dockerhub_image}:latest + +push.${IMAGE_NAME}: + docker push ${dockerhub_image}:latest + +save.${IMAGE_NAME}: + docker save -o ${IMAGE_NAME}.tar ${dockerhub_image}:${sha} \ No newline at end of file From ed96cd23635cbeebedc2698137ecc6a17af1e6b4 Mon Sep 17 00:00:00 2001 From: trent-codecov Date: Sat, 9 Dec 2023 13:21:02 -0500 Subject: [PATCH 09/17] Adding test api ci --- .github/workflows/test-api-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-api-ci.yml b/.github/workflows/test-api-ci.yml index 121887b5..b46109ba 100644 --- a/.github/workflows/test-api-ci.yml +++ b/.github/workflows/test-api-ci.yml @@ -1,4 +1,4 @@ -name: CI +name: Test API Image CI on: push: From cf2afcacdc9a9123af00e8ca01777f4be215e68a Mon Sep 17 00:00:00 2001 From: trent-codecov Date: Sat, 9 Dec 2023 13:23:22 -0500 Subject: [PATCH 10/17] Adding test api ci --- .github/workflows/test-api-ci.yml | 4 ++-- Makefile | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test-api-ci.yml b/.github/workflows/test-api-ci.yml index b46109ba..489e34c1 100644 --- a/.github/workflows/test-api-ci.yml +++ b/.github/workflows/test-api-ci.yml @@ -23,7 +23,7 @@ jobs: secrets: inherit with: push: false - image_name: test-api + image_name: codecov-javascript-bundler-plugins-test-api docker_path: integration-tests/test-api/Dockerfile push: name: Build API Test @@ -32,5 +32,5 @@ jobs: secrets: inherit with: push: true - image_name: test-api + image_name: codecov-javascript-bundler-plugins-test-api docker_path: integration-tests/test-api/Dockerfile diff --git a/Makefile b/Makefile index 178cd508..3f3f3cfd 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ DOCKERHUB_REPO ?= codecov -IMAGE_NAME ?= test-api +IMAGE_NAME ?= codecov-javascript-bundler-plugins-test-api DOCKER_PATH ?= integration-tests/test-api/Dockerfile - +sha := $(shell git rev-parse --short=7 HEAD) dockerhub_image := ${DOCKERHUB_REPO}/${IMAGE_NAME} export DOCKER_BUILDKIT := 1 @@ -11,7 +11,7 @@ build.${IMAGE_NAME}: --label "org.label-schema.build-date"="$(build_date)" \ --label "org.label-schema.name"="${IMAGE_NAME}" \ --label "org.label-schema.vendor"="Codecov" \ - --label "org.label-schema.version"="${release_version}-${sha}" + --label "org.label-schema.version"="${sha}" tag.${IMAGE_NAME}: docker tag ${dockerhub_image}:${sha} ${dockerhub_image}:latest From cf87942d5b8c9509cb7c579cbdd611b891bd38cc Mon Sep 17 00:00:00 2001 From: trent-codecov Date: Sat, 9 Dec 2023 13:31:41 -0500 Subject: [PATCH 11/17] Adding test api ci --- .github/workflows/test-api-ci.yml | 4 ++-- Makefile | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-api-ci.yml b/.github/workflows/test-api-ci.yml index 489e34c1..5393a7f6 100644 --- a/.github/workflows/test-api-ci.yml +++ b/.github/workflows/test-api-ci.yml @@ -24,7 +24,7 @@ jobs: with: push: false image_name: codecov-javascript-bundler-plugins-test-api - docker_path: integration-tests/test-api/Dockerfile + docker_path: integration-tests/test-api push: name: Build API Test if: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/main' && github.repository_owner == 'codecov' }} @@ -33,4 +33,4 @@ jobs: with: push: true image_name: codecov-javascript-bundler-plugins-test-api - docker_path: integration-tests/test-api/Dockerfile + docker_path: integration-tests/test-api diff --git a/Makefile b/Makefile index 3f3f3cfd..3a3811d5 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,12 @@ DOCKERHUB_REPO ?= codecov IMAGE_NAME ?= codecov-javascript-bundler-plugins-test-api -DOCKER_PATH ?= integration-tests/test-api/Dockerfile +DOCKER_PATH ?= integration-tests/test-api sha := $(shell git rev-parse --short=7 HEAD) dockerhub_image := ${DOCKERHUB_REPO}/${IMAGE_NAME} export DOCKER_BUILDKIT := 1 build.${IMAGE_NAME}: - docker build -f ${DOCKER_PATH} . -t ${dockerhub_image}:latest \ + docker build -f ${DOCKER_PATH}/Dockerfile ${DOCKER_PATH} -t ${dockerhub_image}:latest \ -t ${dockerhub_image}:${sha} \ --label "org.label-schema.build-date"="$(build_date)" \ --label "org.label-schema.name"="${IMAGE_NAME}" \ From 40a0f1008ab6384a5e26118fbe1a4b70d19b5b06 Mon Sep 17 00:00:00 2001 From: trent-codecov Date: Sat, 9 Dec 2023 13:32:58 -0500 Subject: [PATCH 12/17] Adding test api ci --- integration-tests/test-api/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-tests/test-api/Dockerfile b/integration-tests/test-api/Dockerfile index 3e4245e1..53e342a0 100644 --- a/integration-tests/test-api/Dockerfile +++ b/integration-tests/test-api/Dockerfile @@ -1,4 +1,4 @@ -FROM --platform=arm64 node:20-alpine +FROM node:20-alpine WORKDIR /app ENV NODE_ENV=production From 03138985d11eb06477fc9aeda7c60ec9664e7a11 Mon Sep 17 00:00:00 2001 From: trent-codecov Date: Sat, 9 Dec 2023 13:40:37 -0500 Subject: [PATCH 13/17] Set build platform --- Makefile | 10 +++++++++- integration-tests/test-api/Dockerfile | 4 +++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 3a3811d5..46b6d961 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,13 @@ DOCKERHUB_REPO ?= codecov IMAGE_NAME ?= codecov-javascript-bundler-plugins-test-api DOCKER_PATH ?= integration-tests/test-api +OS_NAME := $(shell uname -s | tr A-Z a-z) +BUILD_PLATFORM := +ifeq ($(OS_NAME),darwin) + BUILD_PLATFORM := arm64 +else + BUILD_PLATFORM := linux/amd64 +endif sha := $(shell git rev-parse --short=7 HEAD) dockerhub_image := ${DOCKERHUB_REPO}/${IMAGE_NAME} export DOCKER_BUILDKIT := 1 @@ -11,7 +18,8 @@ build.${IMAGE_NAME}: --label "org.label-schema.build-date"="$(build_date)" \ --label "org.label-schema.name"="${IMAGE_NAME}" \ --label "org.label-schema.vendor"="Codecov" \ - --label "org.label-schema.version"="${sha}" + --label "org.label-schema.version"="${sha}" \ + --build-arg BUILDPLATFORM=${BUILD_PLATFORM} tag.${IMAGE_NAME}: docker tag ${dockerhub_image}:${sha} ${dockerhub_image}:latest diff --git a/integration-tests/test-api/Dockerfile b/integration-tests/test-api/Dockerfile index 53e342a0..23393196 100644 --- a/integration-tests/test-api/Dockerfile +++ b/integration-tests/test-api/Dockerfile @@ -1,4 +1,6 @@ -FROM node:20-alpine +# syntax=docker/dockerfile:1 +ARG BUILDPLATFORM=arm64 +FROM --platform=$BUILDPLATFORM node:20-alpine WORKDIR /app ENV NODE_ENV=production From 363aba5c09237f582c2216d55b8c6eedd2ffd399 Mon Sep 17 00:00:00 2001 From: trent-codecov Date: Sat, 9 Dec 2023 13:40:43 -0500 Subject: [PATCH 14/17] Set build platform --- .github/workflows/test-api-ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-api-ci.yml b/.github/workflows/test-api-ci.yml index 5393a7f6..9bc9820b 100644 --- a/.github/workflows/test-api-ci.yml +++ b/.github/workflows/test-api-ci.yml @@ -4,11 +4,11 @@ on: push: branches: - main -# paths: -# - integration-tests/test-api/** + paths: + - integration-tests/test-api/** pull_request: -# paths: -# - integration-tests/test-api/** + paths: + - integration-tests/test-api/** concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} From 50be7c21b8d728d54560c7bdd6853fbed4e0821d Mon Sep 17 00:00:00 2001 From: trent-codecov Date: Sat, 9 Dec 2023 13:44:46 -0500 Subject: [PATCH 15/17] Set build platform --- .github/workflows/test-api-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-api-ci.yml b/.github/workflows/test-api-ci.yml index 9bc9820b..be586888 100644 --- a/.github/workflows/test-api-ci.yml +++ b/.github/workflows/test-api-ci.yml @@ -19,7 +19,7 @@ jobs: build: name: Build API Test if: github.event_name != 'push' - uses: codecov/gha-workflows/.github/workflows/build-and-push-dockerhub.yml@trent/build-push-dockerhub + uses: codecov/gha-workflows/.github/workflows/build-and-push-dockerhub.yml@v1.2.14 secrets: inherit with: push: false @@ -28,7 +28,7 @@ jobs: push: name: Build API Test if: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/main' && github.repository_owner == 'codecov' }} - uses: codecov/gha-workflows/.github/workflows/build-and-push-dockerhub.yml@trent/build-push-dockerhub + uses: codecov/gha-workflows/.github/workflows/build-and-push-dockerhub.yml@v1.2.14 secrets: inherit with: push: true From 5c45bd7ee0009621b54838f344d3c43e298e246d Mon Sep 17 00:00:00 2001 From: trent-codecov Date: Sat, 9 Dec 2023 13:48:34 -0500 Subject: [PATCH 16/17] Set build platform --- .github/workflows/test-api-ci.yml | 15 --------------- .github/workflows/test-api-push.yml | 24 ++++++++++++++++++++++++ Makefile | 2 +- 3 files changed, 25 insertions(+), 16 deletions(-) create mode 100644 .github/workflows/test-api-push.yml diff --git a/.github/workflows/test-api-ci.yml b/.github/workflows/test-api-ci.yml index be586888..6dba5a20 100644 --- a/.github/workflows/test-api-ci.yml +++ b/.github/workflows/test-api-ci.yml @@ -1,11 +1,6 @@ name: Test API Image CI on: - push: - branches: - - main - paths: - - integration-tests/test-api/** pull_request: paths: - integration-tests/test-api/** @@ -18,19 +13,9 @@ concurrency: jobs: build: name: Build API Test - if: github.event_name != 'push' uses: codecov/gha-workflows/.github/workflows/build-and-push-dockerhub.yml@v1.2.14 secrets: inherit with: push: false image_name: codecov-javascript-bundler-plugins-test-api docker_path: integration-tests/test-api - push: - name: Build API Test - if: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/main' && github.repository_owner == 'codecov' }} - uses: codecov/gha-workflows/.github/workflows/build-and-push-dockerhub.yml@v1.2.14 - secrets: inherit - with: - push: true - image_name: codecov-javascript-bundler-plugins-test-api - docker_path: integration-tests/test-api diff --git a/.github/workflows/test-api-push.yml b/.github/workflows/test-api-push.yml new file mode 100644 index 00000000..5acdb085 --- /dev/null +++ b/.github/workflows/test-api-push.yml @@ -0,0 +1,24 @@ +name: Test API Image Push + +on: + push: + branches: + - main + paths: + - integration-tests/test-api/** + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + + +jobs: + push: + name: Push API Test + if: github.repository_owner == 'codecov' + uses: codecov/gha-workflows/.github/workflows/build-and-push-dockerhub.yml@v1.2.14 + secrets: inherit + with: + push: true + image_name: codecov-javascript-bundler-plugins-test-api + docker_path: integration-tests/test-api diff --git a/Makefile b/Makefile index 46b6d961..102f3892 100644 --- a/Makefile +++ b/Makefile @@ -28,4 +28,4 @@ push.${IMAGE_NAME}: docker push ${dockerhub_image}:latest save.${IMAGE_NAME}: - docker save -o ${IMAGE_NAME}.tar ${dockerhub_image}:${sha} \ No newline at end of file + docker save -o ${IMAGE_NAME}.tar ${dockerhub_image}:${sha} From 9951331f041debce322c1670fa10b96776236695 Mon Sep 17 00:00:00 2001 From: trent-codecov Date: Sat, 9 Dec 2023 13:56:15 -0500 Subject: [PATCH 17/17] Set build platform --- Makefile | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 102f3892..629b8f40 100644 --- a/Makefile +++ b/Makefile @@ -2,12 +2,8 @@ DOCKERHUB_REPO ?= codecov IMAGE_NAME ?= codecov-javascript-bundler-plugins-test-api DOCKER_PATH ?= integration-tests/test-api OS_NAME := $(shell uname -s | tr A-Z a-z) -BUILD_PLATFORM := -ifeq ($(OS_NAME),darwin) - BUILD_PLATFORM := arm64 -else - BUILD_PLATFORM := linux/amd64 -endif +build_date := $(shell git show -s --date=iso8601-strict --pretty=format:%cd $$sha) +BUILD_PLATFORM := $(shell docker system info --format '{{.OSType}}/{{.Architecture}}') sha := $(shell git rev-parse --short=7 HEAD) dockerhub_image := ${DOCKERHUB_REPO}/${IMAGE_NAME} export DOCKER_BUILDKIT := 1 @@ -26,6 +22,7 @@ tag.${IMAGE_NAME}: push.${IMAGE_NAME}: docker push ${dockerhub_image}:latest + docker push ${dockerhub_image}:${sha} save.${IMAGE_NAME}: docker save -o ${IMAGE_NAME}.tar ${dockerhub_image}:${sha}