From c538e24353e15584d7cd34e5035a646b1bfd4cc5 Mon Sep 17 00:00:00 2001 From: nicomiguelino Date: Fri, 8 Nov 2024 08:16:24 -0800 Subject: [PATCH 1/5] chore: remove the teamcity npm script; update unit test workflow --- .github/workflows/build.yaml | 30 ++++++++++++++++-------------- package.json | 1 - 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index f54a6d3..7222f2c 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -14,30 +14,32 @@ jobs: deploy: runs-on: ubuntu-latest - name: Build and generate Artifact + name: Build and generate artifact steps: - name: Checkout uses: actions/checkout@v4 - - name: Build + - name: Build Docker images run: | docker compose build # This step should probably be rewritten - - name: Generate + - name: Run unit tests run: | docker run \ - --rm \ + --rm -ti \ + -v $(pwd):/app:delegated \ + -v /app/node_modules \ sce_webpack:latest \ - /bin/bash -c "npx webpack --config webpack.dev.js && npm run teamcity" + /bin/bash -c "npx webpack --config webpack.dev.js && npm run test" + # TODO: Uncomment this step when ready. + # - name: Generate + # run: | + # mkdir artifacts - - name: Generate - run: | - mkdir artifacts - - docker run \ - --rm \ - -v $(pwd)/artifacts:/app/artifacts:delegated \ - sce_webpack:latest \ - /bin/bash -c "npm run build && cd dist && zip -r ../artifacts/screenly-chrome-extension.zip *" + # docker run \ + # --rm \ + # -v $(pwd)/artifacts:/app/artifacts:delegated \ + # sce_webpack:latest \ + # /bin/bash -c "npm run build && cd dist && zip -r ../artifacts/screenly-chrome-extension.zip *" diff --git a/package.json b/package.json index 5d8adfe..3661b86 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,6 @@ }, "scripts": { "test": "karma start --single-run --browsers ChromeHeadlessNoSandbox karma.conf.js", - "teamcity": "karma start --reporters teamcity --colors false --single-run --browsers ChromeHeadlessNoSandbox karma.conf.js", "build": "webpack --config webpack.prod.js" }, "author": "Screenly, Inc." From 8f793813639018d181ebeed48021b5f04b50d16e Mon Sep 17 00:00:00 2001 From: nicomiguelino Date: Fri, 8 Nov 2024 08:20:07 -0800 Subject: [PATCH 2/5] chore(ci): don't enable TTY when running `docker run` in CI --- .github/workflows/build.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 7222f2c..2ab0f3d 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -23,11 +23,10 @@ jobs: run: | docker compose build - # This step should probably be rewritten - name: Run unit tests run: | docker run \ - --rm -ti \ + --rm \ -v $(pwd):/app:delegated \ -v /app/node_modules \ sce_webpack:latest \ From 9ab0e2b07facd70e27737b8363b488917dc09017 Mon Sep 17 00:00:00 2001 From: nicomiguelino Date: Fri, 8 Nov 2024 08:50:57 -0800 Subject: [PATCH 3/5] test: resolve import errors in `test-main.js` --- src/test/spec/test-main.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/spec/test-main.js b/src/test/spec/test-main.js index ccc61b9..649d9cd 100644 --- a/src/test/spec/test-main.js +++ b/src/test/spec/test-main.js @@ -6,7 +6,7 @@ import { fetchToken, State -} from "../../assets/js/main"; +} from "../../assets/js/main.mjs"; function mockFetchResponse(status, statusText, body) { return Promise.resolve({ @@ -247,4 +247,4 @@ describe("State", function() { }); }); -}); \ No newline at end of file +}); From 50c3536630fbbfa0961bc39f0e76ae6bcde81ebf Mon Sep 17 00:00:00 2001 From: nicomiguelino Date: Fri, 8 Nov 2024 09:10:25 -0800 Subject: [PATCH 4/5] chore(ci): re-enable artifact build step in Actions --- .github/workflows/build.yaml | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 2ab0f3d..2fcf517 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -32,13 +32,18 @@ jobs: sce_webpack:latest \ /bin/bash -c "npx webpack --config webpack.dev.js && npm run test" - # TODO: Uncomment this step when ready. - # - name: Generate - # run: | - # mkdir artifacts + - name: Build and package the extension + run: | + mkdir artifacts + docker run \ + --rm \ + -v $(pwd)/artifacts:/app/artifacts:delegated \ + -v /app/artifacts/node_modules \ + sce_webpack:latest \ + /bin/bash -c "npm run build && cd dist && zip -r ../artifacts/screenly-chrome-extension.zip *" - # docker run \ - # --rm \ - # -v $(pwd)/artifacts:/app/artifacts:delegated \ - # sce_webpack:latest \ - # /bin/bash -c "npm run build && cd dist && zip -r ../artifacts/screenly-chrome-extension.zip *" + - name: Upload archive as artifact + uses: actions/upload-artifact@v4 + with: + name: screenly-chrome-extension + path: artifacts/screenly-chrome-extension.zip From 28ad041164e0d815e647366de4703ba675e288a1 Mon Sep 17 00:00:00 2001 From: nicomiguelino Date: Fri, 8 Nov 2024 09:19:30 -0800 Subject: [PATCH 5/5] chore(workflow): convert the job and step names to title case --- .github/workflows/build.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 2fcf517..23340c1 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,5 +1,5 @@ --- -name: Build +name: Build Screenly Chrome Extension on: pull_request: @@ -14,7 +14,7 @@ jobs: deploy: runs-on: ubuntu-latest - name: Build and generate artifact + name: Build and Generate Artifact steps: - name: Checkout uses: actions/checkout@v4 @@ -23,7 +23,7 @@ jobs: run: | docker compose build - - name: Run unit tests + - name: Run Unit Tests run: | docker run \ --rm \ @@ -32,7 +32,7 @@ jobs: sce_webpack:latest \ /bin/bash -c "npx webpack --config webpack.dev.js && npm run test" - - name: Build and package the extension + - name: Build and Package the Extension run: | mkdir artifacts docker run \ @@ -42,7 +42,7 @@ jobs: sce_webpack:latest \ /bin/bash -c "npm run build && cd dist && zip -r ../artifacts/screenly-chrome-extension.zip *" - - name: Upload archive as artifact + - name: Upload Archive as Artifact uses: actions/upload-artifact@v4 with: name: screenly-chrome-extension