Skip to content

Commit

Permalink
Merge pull request #76 from dependabot/brrygrdn/mystery-dist-diff
Browse files Browse the repository at this point in the history
Consistency and clarity pass on our workflows
  • Loading branch information
brrygrdn authored Feb 11, 2022
2 parents 8da49e9 + b1090a3 commit 8d0b958
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 26 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/check-dist.yml
Original file line number Diff line number Diff line change
@@ -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
12 changes: 3 additions & 9 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
26 changes: 20 additions & 6 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
28 changes: 17 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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'",
Expand Down
9 changes: 9 additions & 0 deletions script/check-diff
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 8d0b958

Please sign in to comment.