From 1b53372e9ffb4d70c06ddc11d73afd41b09999af Mon Sep 17 00:00:00 2001 From: ValentinFutterer Date: Sun, 14 Apr 2024 15:32:17 +0200 Subject: [PATCH 1/7] Add basic GitHub workflow that builds and tests the frontend --- .github/workflows/blank.yml | 35 ++++++++++++++++---------- frontend/indiestream/package-lock.json | 1 + frontend/indiestream/package.json | 7 ++++-- 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/.github/workflows/blank.yml b/.github/workflows/blank.yml index 0160ff3..a75cb15 100644 --- a/.github/workflows/blank.yml +++ b/.github/workflows/blank.yml @@ -1,14 +1,16 @@ -# This is a basic workflow to help you get started with Actions - name: CI # Controls when the workflow will run on: # Triggers the workflow on push or pull request events but only for the "develop" branch push: - branches: [ "develop" ] + branches: + - develop + pull_request: - branches: [ "develop" ] + branches: + - develop + - main # Allows you to run this workflow manually from the Actions tab workflow_dispatch: @@ -23,14 +25,21 @@ jobs: # Steps represent a sequence of tasks that will be executed as part of the job steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + + - name: Install dependencies + run: npm run ci:install + + - name: Audit dependencies + run: npm run ci:audit - # Runs a single command using the runners shell - - name: Run a one-line script - run: echo Hello, world! + - name: Build + run: npm run build - # Runs a set of commands using the runners shell - - name: Run a multi-line script - run: | - echo Add other actions to build, - echo test, and deploy your project. + - name: Test + run: npm run test diff --git a/frontend/indiestream/package-lock.json b/frontend/indiestream/package-lock.json index ae17d0a..ddeb56c 100644 --- a/frontend/indiestream/package-lock.json +++ b/frontend/indiestream/package-lock.json @@ -25,6 +25,7 @@ "@angular/cli": "^17.3.3", "@angular/compiler-cli": "^17.3.0", "@types/jasmine": "~5.1.0", + "@types/node": "^20.11.17", "jasmine-core": "~5.1.0", "karma": "~6.4.0", "karma-chrome-launcher": "~3.2.0", diff --git a/frontend/indiestream/package.json b/frontend/indiestream/package.json index 7ade5e0..0249fc5 100644 --- a/frontend/indiestream/package.json +++ b/frontend/indiestream/package.json @@ -4,9 +4,11 @@ "scripts": { "ng": "ng", "start": "ng serve", - "build": "ng build", + "build": "ng build indiestream", "watch": "ng build --watch --configuration development", - "test": "ng test" + "test": "ng test indiestream", + "ci:audit": "npm audit --audit-level high", + "ci:install": "npm ci" }, "private": true, "dependencies": { @@ -27,6 +29,7 @@ "@angular/cli": "^17.3.3", "@angular/compiler-cli": "^17.3.0", "@types/jasmine": "~5.1.0", + "@types/node": "^20.11.17", "jasmine-core": "~5.1.0", "karma": "~6.4.0", "karma-chrome-launcher": "~3.2.0", From 31634724e75c0eda463555734fbc5bf91cc21011 Mon Sep 17 00:00:00 2001 From: ValentinFutterer Date: Sun, 14 Apr 2024 15:52:58 +0200 Subject: [PATCH 2/7] Add working directory to pipeline commands --- .github/workflows/blank.yml | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/.github/workflows/blank.yml b/.github/workflows/blank.yml index a75cb15..3771367 100644 --- a/.github/workflows/blank.yml +++ b/.github/workflows/blank.yml @@ -1,8 +1,6 @@ name: CI -# Controls when the workflow will run on: - # Triggers the workflow on push or pull request events but only for the "develop" branch push: branches: - develop @@ -12,19 +10,17 @@ on: - develop - main - # Allows you to run this workflow manually from the Actions tab workflow_dispatch: -# A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: - # This workflow contains a single job called "build" - build: - # The type of runner that the job will run on + test_frontend: runs-on: ubuntu-latest - # Steps represent a sequence of tasks that will be executed as part of the job + defaults: + run: + working-directory: ./frontend/indiestream + steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v4 - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v4 From 23641640fcb60716655f450cd820ff7e1f86aeb1 Mon Sep 17 00:00:00 2001 From: ValentinFutterer Date: Sun, 14 Apr 2024 15:56:18 +0200 Subject: [PATCH 3/7] Add fixed node version --- .github/workflows/blank.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/blank.yml b/.github/workflows/blank.yml index 3771367..24f88f0 100644 --- a/.github/workflows/blank.yml +++ b/.github/workflows/blank.yml @@ -16,6 +16,10 @@ jobs: test_frontend: runs-on: ubuntu-latest + strategy: + matrix: + node-version: [ '20.x' ] + defaults: run: working-directory: ./frontend/indiestream From 2497c4424f859cd12a1a45a2f21eb41dbe8e6c2b Mon Sep 17 00:00:00 2001 From: ValentinFutterer Date: Sun, 14 Apr 2024 16:07:19 +0200 Subject: [PATCH 4/7] Try to solve the non-root issue --- .github/workflows/blank.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/blank.yml b/.github/workflows/blank.yml index 24f88f0..dd521cc 100644 --- a/.github/workflows/blank.yml +++ b/.github/workflows/blank.yml @@ -31,6 +31,7 @@ jobs: with: node-version: ${{ matrix.node-version }} cache: 'npm' + cache-dependency-path: ./frontend/indiestream/package-lock.json - name: Install dependencies run: npm run ci:install From 68a9be339d00fbdc30913585cdb43b8db542d53f Mon Sep 17 00:00:00 2001 From: ValentinFutterer Date: Sun, 14 Apr 2024 16:24:25 +0200 Subject: [PATCH 5/7] Should fail --- .github/workflows/blank.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/blank.yml b/.github/workflows/blank.yml index dd521cc..8e2f904 100644 --- a/.github/workflows/blank.yml +++ b/.github/workflows/blank.yml @@ -16,10 +16,6 @@ jobs: test_frontend: runs-on: ubuntu-latest - strategy: - matrix: - node-version: [ '20.x' ] - defaults: run: working-directory: ./frontend/indiestream @@ -31,6 +27,7 @@ jobs: with: node-version: ${{ matrix.node-version }} cache: 'npm' + # needed because project is not in root cache-dependency-path: ./frontend/indiestream/package-lock.json - name: Install dependencies @@ -42,5 +39,6 @@ jobs: - name: Build run: npm run build - - name: Test - run: npm run test + # no tests yet + #- name: Test + # run: npm run test From b2d98c5f6e4349edeb5ce229afc8e82607c5afdb Mon Sep 17 00:00:00 2001 From: ValentinFutterer Date: Sun, 14 Apr 2024 16:25:52 +0200 Subject: [PATCH 6/7] Should fail --- .github/workflows/blank.yml | 2 +- frontend/indiestream/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/blank.yml b/.github/workflows/blank.yml index 8e2f904..30ff3da 100644 --- a/.github/workflows/blank.yml +++ b/.github/workflows/blank.yml @@ -26,9 +26,9 @@ jobs: uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} - cache: 'npm' # needed because project is not in root cache-dependency-path: ./frontend/indiestream/package-lock.json + cache: 'npm' - name: Install dependencies run: npm run ci:install diff --git a/frontend/indiestream/package.json b/frontend/indiestream/package.json index 0249fc5..dbafa6d 100644 --- a/frontend/indiestream/package.json +++ b/frontend/indiestream/package.json @@ -7,7 +7,7 @@ "build": "ng build indiestream", "watch": "ng build --watch --configuration development", "test": "ng test indiestream", - "ci:audit": "npm audit --audit-level high", + "ci:audit": "npm audit --audit-level low", "ci:install": "npm ci" }, "private": true, From 40ce30822e240b5f3c6e0781bac59e00292711ff Mon Sep 17 00:00:00 2001 From: ValentinFutterer Date: Sun, 14 Apr 2024 16:27:27 +0200 Subject: [PATCH 7/7] Finish --- frontend/indiestream/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/indiestream/package.json b/frontend/indiestream/package.json index dbafa6d..0249fc5 100644 --- a/frontend/indiestream/package.json +++ b/frontend/indiestream/package.json @@ -7,7 +7,7 @@ "build": "ng build indiestream", "watch": "ng build --watch --configuration development", "test": "ng test indiestream", - "ci:audit": "npm audit --audit-level low", + "ci:audit": "npm audit --audit-level high", "ci:install": "npm ci" }, "private": true,