From 69795d6e93c9c1745da9d386a99413287c04a5ab Mon Sep 17 00:00:00 2001 From: Gergo Ivan Date: Fri, 25 Feb 2022 16:49:17 +0100 Subject: [PATCH 1/3] Add code coverage report --- .github/workflows/npm-test.yml | 35 ------------------ .github/workflows/test.yml | 65 ++++++++++++++++++++++++++++++++++ tsconfig.json | 16 ++------- 3 files changed, 68 insertions(+), 48 deletions(-) delete mode 100644 .github/workflows/npm-test.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/npm-test.yml b/.github/workflows/npm-test.yml deleted file mode 100644 index ee18e61c..00000000 --- a/.github/workflows/npm-test.yml +++ /dev/null @@ -1,35 +0,0 @@ ---- -name: Pull Request NPM Checks -on: [pull_request] -concurrency: - group: ci-${{ github.ref }} - cancel-in-progress: true -jobs: - npm-test: - name: NPM test - runs-on: ubuntu-latest - steps: - - name: Checkout Sources - uses: actions/checkout@v2 - - name: Prepare Node.js - uses: actions/setup-node@v1 - with: - node-version: '12.x' - - name: Run `npm install` - run: npm install - - name: Run `npm test` - run: npm test - npm-lint: - name: NPM lint - runs-on: ubuntu-latest - steps: - - name: Checkout Sources - uses: actions/checkout@v2 - - name: Prepare Node.js - uses: actions/setup-node@v1 - with: - node-version: '12.x' - - name: Run `npm install` - run: npm install - - name: Run `npm run lint` - run: npm run lint diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..aefe6e21 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,65 @@ +--- +name: tests + +on: + pull_request: + push: + workflow_dispatch: + inputs: +concurrency: + group: dashboard-${{ github.ref }} + cancel-in-progress: true + +jobs: + tests: + name: Run Tests + runs-on: ubuntu-latest + + steps: + - name: checkout + uses: actions/checkout@v2 + + - uses: actions/setup-node@v2 + with: + node-version: "12.22.0" + cache: "npm" + - name: Install dependencies + run: npm install + + - name: Run Tests + if: github.event_name != 'pull_request' + continue-on-error: true + id: run-tests + run: npm test -- --coverage --watchAll=false > /tmp/coverage_report + + - name: Post Test Coverage Report in PR + uses: ArtiomTr/jest-coverage-report-action@v2 + continue-on-error: true + if: github.event_name == 'pull_request' + with: + test-script: npm run test + annotations: all + + - name: Gain access to test-reports bucket + if: (steps.run-tests.outcome == 'failure' || steps.run-tests.outcome == 'success') && github.ref == 'refs/heads/develop' + uses: google-github-actions/setup-gcloud@master + with: + project_id: "netdata-cloud-testing" + service_account_key: ${{ secrets.TEST_AUTOMATION_SERVICE_ACCOUNT }} + export_default_credentials: true + + - name: Upload report to test-reports bucket + if: (steps.run-tests.outcome == 'failure' || steps.run-tests.outcome == 'success') && github.ref == 'refs/heads/develop' + run: | + gsutil -h "Cache-Control: max-age=0, no-store" cp /tmp/coverage_report gs://${{ secrets.TEST_AUTOMATION_STORAGE_BUCKET }}/${{ github.event.repository.name }}/coverage_report + gsutil acl set project-private gs://${{ secrets.TEST_AUTOMATION_STORAGE_BUCKET }}/${{ github.event.repository.name }}/coverage_report + + - name: Publish test coverage report + if: (steps.run-tests.outcome == 'failure' || steps.run-tests.outcome == 'success') && github.ref == 'refs/heads/develop' + uses: aurelien-baudet/workflow-dispatch@v2 + with: + repo: netdata/cloud-workflows + ref: refs/heads/main + workflow: test_coverage_publisher.yml + token: ${{ secrets.TEST_AUTOMATION_TOKEN }} + inputs: '{ "service-name": "${{ github.event.repository.name }}"}' diff --git a/tsconfig.json b/tsconfig.json index 8bb4d8b7..418ca0bc 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,11 +9,7 @@ "inlineSources": true, "sourceRoot": "/", "noImplicitAny": false, - "lib": [ - "esnext", - "dom", - "dom.iterable" - ], + "lib": ["esnext", "dom", "dom.iterable"], "module": "esnext", "target": "es2018", "jsx": "react", @@ -28,12 +24,6 @@ "noEmit": true, "declaration": true }, - "include": [ - "./src/**/*" - ], - "exclude": [ - "/node_modules/", - "**/*.test.ts", - "**/*.test.tsx" - ] + "include": ["./src/**/*", "src/vendor/dygraph-c91c859.min.js"], + "exclude": ["/node_modules/", "**/*.test.ts", "**/*.test.tsx"] } From 41eb23294416f01b64871760a6abf1bc6c49559a Mon Sep 17 00:00:00 2001 From: Gergo Ivan Date: Tue, 1 Mar 2022 13:02:32 +0100 Subject: [PATCH 2/3] Fix review comments --- .github/workflows/test.yml | 11 ++++++----- tsconfig.json | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index aefe6e21..a2599734 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,12 +2,12 @@ name: tests on: - pull_request: push: + branches: [master] workflow_dispatch: - inputs: + concurrency: - group: dashboard-${{ github.ref }} + group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: @@ -21,7 +21,7 @@ jobs: - uses: actions/setup-node@v2 with: - node-version: "12.22.0" + node-version: "12.x" cache: "npm" - name: Install dependencies run: npm install @@ -51,7 +51,8 @@ jobs: - name: Upload report to test-reports bucket if: (steps.run-tests.outcome == 'failure' || steps.run-tests.outcome == 'success') && github.ref == 'refs/heads/develop' run: | - gsutil -h "Cache-Control: max-age=0, no-store" cp /tmp/coverage_report gs://${{ secrets.TEST_AUTOMATION_STORAGE_BUCKET }}/${{ github.event.repository.name }}/coverage_report + gsutil -h "Cache-Control: max-age=0, no-store" cp \ + /tmp/coverage_report gs://${{ secrets.TEST_AUTOMATION_STORAGE_BUCKET }}/${{ github.event.repository.name }}/coverage_report gsutil acl set project-private gs://${{ secrets.TEST_AUTOMATION_STORAGE_BUCKET }}/${{ github.event.repository.name }}/coverage_report - name: Publish test coverage report diff --git a/tsconfig.json b/tsconfig.json index 418ca0bc..3699a667 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -24,6 +24,6 @@ "noEmit": true, "declaration": true }, - "include": ["./src/**/*", "src/vendor/dygraph-c91c859.min.js"], + "include": ["./src/**/*"], "exclude": ["/node_modules/", "**/*.test.ts", "**/*.test.tsx"] } From 9f8a6c7b9add4387e5dbc3c7599796dc095ffac6 Mon Sep 17 00:00:00 2001 From: Gergo Ivan Date: Wed, 16 Mar 2022 10:15:54 +0100 Subject: [PATCH 3/3] Run tests on pull requests --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a2599734..eebf8a48 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,7 +2,7 @@ name: tests on: - push: + pull_request: branches: [master] workflow_dispatch: