From b91343c38a207b7d5d794a626227ee6070d8936c Mon Sep 17 00:00:00 2001 From: nefelitav Date: Wed, 13 Mar 2024 18:54:07 +0100 Subject: [PATCH 1/5] add lighthouse --- .github/workflows/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5b793b6..f307b71 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -34,6 +34,8 @@ jobs: run: npm run lint - name: Run unit tests run: npm run test + - name: Run Performance tests + uses: treosh/lighthouse-ci-action@v2 - name: Dependency Check uses: dependency-check/Dependency-Check_Action@main with: From c2d2bf785908c407d9a28649ef3dd399888da14a Mon Sep 17 00:00:00 2001 From: nefelitav Date: Wed, 13 Mar 2024 19:00:20 +0100 Subject: [PATCH 2/5] make a report --- .github/workflows/main.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f307b71..e43f761 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -36,6 +36,10 @@ jobs: run: npm run test - name: Run Performance tests uses: treosh/lighthouse-ci-action@v2 + with: + budgetPath: ./budget.json + uploadArtifacts: true + temporaryPublicStorage: true - name: Dependency Check uses: dependency-check/Dependency-Check_Action@main with: From e095c2f30c82e0b931077054b2ab31423660ccbe Mon Sep 17 00:00:00 2001 From: nefelitav Date: Wed, 13 Mar 2024 19:04:02 +0100 Subject: [PATCH 3/5] add budget.json --- budget.json | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 budget.json diff --git a/budget.json b/budget.json new file mode 100644 index 0000000..6e46527 --- /dev/null +++ b/budget.json @@ -0,0 +1,15 @@ +[ + { + "path": "/*", + "resourceSizes": [ + { + "resourceType": "document", + "budget": 18 + }, + { + "resourceType": "total", + "budget": 200 + } + ] + } + ] \ No newline at end of file From 3064436741bb606a9035eebf6ab4464fa66cde96 Mon Sep 17 00:00:00 2001 From: nefelitav Date: Wed, 13 Mar 2024 19:12:44 +0100 Subject: [PATCH 4/5] organize files --- .github/workflows/main.yml | 113 +++++++++++++++++++++---------------- 1 file changed, 63 insertions(+), 50 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e43f761..9b373a1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,4 +1,5 @@ -name: Build, Test and Push +name: Build, Test, and Push + on: push: branches: @@ -6,9 +7,10 @@ on: pull_request: branches: - "**" + jobs: scan: - name: gitleaks + name: Gitleaks Scan runs-on: ubuntu-latest steps: - name: Checkout code @@ -19,54 +21,65 @@ jobs: uses: gitleaks/gitleaks-action@v2 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITLEAKS_LICENSE: ${{ secrets.GITLEAKS_LICENSE}} - build: + GITLEAKS_LICENSE: ${{ secrets.GITLEAKS_LICENSE }} + + build-test: + name: Build and Test runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Setup Node - uses: actions/setup-node@v3 - with: - node-version: 20 - - name: Install dependencies - run: npm install - - name: Run lint tests - run: npm run lint - - name: Run unit tests - run: npm run test - - name: Run Performance tests - uses: treosh/lighthouse-ci-action@v2 - with: - budgetPath: ./budget.json - uploadArtifacts: true - temporaryPublicStorage: true - - name: Dependency Check - uses: dependency-check/Dependency-Check_Action@main - with: - project: 'messaging-app' - path: '.' - format: 'HTML' - out: 'reports' - args: > - --failOnCVSS 7 - --enableRetired - - name: Upload Dependency Check Test results - uses: actions/upload-artifact@master - with: - name: Dependency Check report - path: ${{github.workspace}}/reports - - name: Login to Docker Hub - uses: docker/login-action@v3.0.0 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and run docker containers - run: | - docker-compose up -d && \ + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: 14 + + - name: Install dependencies + run: npm install + + - name: Run lint tests + run: npm run lint + + - name: Run unit tests + run: npm run test + + - name: Dependency Check + uses: dependency-check/Dependency-Check_Action@main + with: + project: 'messaging-app' + path: '.' + format: 'HTML' + out: 'reports' + args: > + --failOnCVSS 7 + --enableRetired + + - name: Upload Dependency Check Report + uses: actions/upload-artifact@v2 + with: + name: Dependency Check report + path: ${{ github.workspace }}/reports + + docker: + name: Docker Build and Push + runs-on: ubuntu-latest + needs: build-test + steps: + - name: Login to Docker Hub + uses: docker/login-action@v3.0.0 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and Run Docker Containers + run: | + docker-compose up -d && \ docker ps && sleep 5 - - name: Build and push to Docker Hub - uses: docker/build-push-action@v5.1.0 - with: - context: . - push: true - tags: dasha12678/messaging-app:latest + + - name: Build and Push to Docker Hub + uses: docker/build-push-action@v5.1.0 + with: + context: . + push: true + tags: dasha12678/messaging-app:latest \ No newline at end of file From 3861a20b4b0b5a8ee493bb02dd2d0a203457ffbc Mon Sep 17 00:00:00 2001 From: nefelitav Date: Wed, 13 Mar 2024 19:17:56 +0100 Subject: [PATCH 5/5] change node version --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9b373a1..e33b0e9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -33,7 +33,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v3 with: - node-version: 14 + node-version: 20 - name: Install dependencies run: npm install