diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml new file mode 100644 index 0000000..fdb4d93 --- /dev/null +++ b/.github/workflows/check-dist.yml @@ -0,0 +1,45 @@ +name: Check dist + +on: + pull_request: + push: + branches: + - main + - 'releases/*' + +jobs: + verify-build: # make sure the checked in dist/ folder matches the output of a rebuild + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + with: + ref: ${{ github.event.pull_request.head.sha }} + + - name: Read .nvmrc + id: nvm + run: echo ::set-output name=NVMRC::$(cat .nvmrc) + + - name: Setup Node.js + uses: actions/setup-node@v1 + with: + node-version: ${{ steps.nvm.outputs.NVMRC }} + + - name: Install NPM dependencies + run: npm ci + + - name: Rebuild the dist/ directory + run: npm run package + + - name: Compare the expected and actual dist/ directories + run: script/check-diff + verify-index-js: # make sure the entrypoint js files run on a clean machine without compiling first + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + ref: ${{ github.event.pull_request.head.sha }} + + - uses: ./ + with: + milliseconds: 1000 diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 1a5e26f..e1e2af3 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -19,24 +19,18 @@ jobs: security-events: write strategy: - fail-fast: false matrix: language: [ 'javascript' ] steps: - - name: Checkout repository - uses: actions/checkout@v2 + - uses: actions/checkout@v2 + with: + ref: ${{ github.event.pull_request.head.sha }} - name: Initialize CodeQL uses: github/codeql-action/init@v1 with: languages: ${{ matrix.language }} - - name: Install dependencies - run: npm ci - - - name: Build executable - run: npm run package - - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v1 diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 981d97d..677a7c2 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -13,16 +13,30 @@ jobs: integration: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - with: - ref: ${{ github.event.pull_request.head.sha }} - token: ${{ secrets.GITHUB_TOKEN }} - name: GPR login run: docker login docker.pkg.github.com -u x -p ${{ secrets.GITHUB_TOKEN }} + - name: GRP pull dependabot/dependabot-updater run: docker pull docker.pkg.github.com/dependabot/dependabot-updater:v1 + - name: GRP pull github/dependabot-update-job-proxy run: docker pull docker.pkg.github.com/github/dependabot-update-job-proxy:v1 - - run: npm ci - - name: Run integration test files + + - uses: actions/checkout@v2 + with: + ref: ${{ github.event.pull_request.head.sha }} + + - name: Read .nvmrc + id: nvm + run: echo ::set-output name=NVMRC::$(cat .nvmrc) + + - name: Setup Node.js + uses: actions/setup-node@v1 + with: + node-version: ${{ steps.nvm.outputs.NVMRC }} + + - name: Install NPM dependencies + run: npm ci + + - name: Run integration tests run: npm run test-integration diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 88da9e2..c4786e4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,24 +8,30 @@ on: - 'releases/*' jobs: - build: # make sure build/ci work properly + test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + with: + ref: ${{ github.event.pull_request.head.sha }} + - name: Read .nvmrc id: nvm run: echo ::set-output name=NVMRC::$(cat .nvmrc) + - name: Setup Node.js uses: actions/setup-node@v1 with: node-version: ${{ steps.nvm.outputs.NVMRC }} - - run: npm ci - - run: npm run all - - run: git diff --quiet dist/ - test: # make sure the action works on a clean machine without building - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: ./ - with: - milliseconds: 1000 + + - name: Install NPM dependencies + run: npm ci + + - name: Check formatting + run: npm run format-check + + - name: Run linter + run: npm run lint-check + + - name: Run tests + run: npm run test diff --git a/package.json b/package.json index ab013d5..0d7f3b5 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,9 @@ "main": "src/main.ts", "scripts": { "format": "prettier --write **/*.ts", + "format-check": "prettier --check **/*.ts", "lint": "eslint --fix **/*.ts", + "lint-check": "eslint **/*.ts", "package": "ncc build -o dist/main src/main.ts --source-map --license licenses.txt && ncc build -o dist/cleanup src/cleanup.ts --source-map --license licenses.txt", "test": "SKIP_INTEGRATION_TESTS=true jest --detectOpenHandles", "test-integration": "jest --detectOpenHandles 'integration'", diff --git a/script/check-diff b/script/check-diff new file mode 100755 index 0000000..bc45833 --- /dev/null +++ b/script/check-diff @@ -0,0 +1,9 @@ +#!/bin/bash + +git diff --quiet dist/ +retVal=$? +if [ $retVal -ne 0 ]; then + echo "Detected uncommitted changes after build:" + git --no-pager diff dist/ + exit 1 +fi