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..eebf8a48 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,66 @@ +--- +name: tests + +on: + pull_request: + branches: [master] + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ 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.x" + 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..3699a667 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/**/*"], + "exclude": ["/node_modules/", "**/*.test.ts", "**/*.test.tsx"] }