Update workflows

This commit is contained in:
Nick Alteen
2023-09-14 10:37:52 -04:00
parent cfa5739bef
commit 8a93a79723
5 changed files with 95 additions and 45 deletions

View File

@@ -1,5 +1,5 @@
name: "javascript-action CodeQL config"
name: JavaScript CodeQL Configuration
paths-ignore:
paths-ignore:
- node_modules
- dist

View File

@@ -1,8 +1,11 @@
# `dist/index.js` is a special file in Actions.
# When you reference an action with `uses:` in a workflow,
# `index.js` is the code that will run.
# For our project, we generate this file through a build process from other source files.
# We need to make sure the checked-in `index.js` actually matches what we expect it to be.
# In JavaScript actions, `dist/index.js` is a special file. When you reference
# an action with `uses:`, `dist/index.js` is the code that will be run. For this
# project, the `dist/index.js` file is generated from other source files through
# the build process. We need to make sure that the checked-in `dist/index.js`
# file matches what is expected from the build.
#
# This workflow will fail if the checked-in `dist/index.js` file does not match
# what is expected from the build.
name: Check dist/
on:
@@ -18,32 +21,43 @@ on:
jobs:
check-dist:
name: Check dist/
runs-on: ubuntu-latest
permissions:
contents: read
statuses: write
steps:
- uses: actions/checkout@v3
- name: Checkout
id: checkout
uses: actions/checkout@v4
- name: Set Node.js 16.x
uses: actions/setup-node@v3.6.0
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 16.x
node-version: 20
cache: npm
- name: Install dependencies
- name: Install Dependencies
id: install
run: npm ci
- name: Rebuild the dist/ directory
run: npm run prepare
- name: Build dist/ Directory
id: build
run: npm run bundle
- name: Compare the expected and actual dist/ directories
- name: Compare Expected and Actual Directories
id: diff
run: |
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
echo "Detected uncommitted changes after build. See status below:"
git diff
if [ "$(git diff --ignore-space-at-eol --text dist/ | wc -l)" -gt "0" ]; then
echo "Detected uncommitted changes after build. See status below:"
git diff --ignore-space-at-eol --text dist/
exit 1
fi
id: diff
# If index.js was different than expected, upload the expected version as an artifact
# If index.js was different than expected, upload the expected version as
# a workflow artifact.
- uses: actions/upload-artifact@v3
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
with:

60
.github/workflows/ci.yml vendored Normal file
View File

@@ -0,0 +1,60 @@
name: Continuous Integration
on:
pull_request:
push:
branches:
- main
- "releases/*"
jobs:
test-javascript:
name: JavaScript Tests
runs-on: ubuntu-latest
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
- name: Setup Node.js
id: setup-node
uses: actions/setup-node@v3
with:
node-version: 20
cache: npm
- name: Install Dependencies
id: npm-ci
run: npm ci
- name: Check Format
id: npm-format-check
run: npm run format:check
- name: Lint
id: npm-lint
run: npm run lint
- name: Test
id: npm-ci-test
run: npm run ci-test
test-action:
name: GitHub Actions Test
runs-on: ubuntu-latest
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
- name: Test Local Action
id: test-action
uses: ./
with:
milliseconds: 1000
- name: Print Output
id: output
run: echo "${{ steps.test-action.outputs.time }}"

View File

@@ -1,25 +0,0 @@
name: "units-test"
on:
pull_request:
push:
branches:
- main
- 'releases/*'
jobs:
# unit tests
units:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: npm ci
- run: npm test
# test action works running from the graph
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./
with:
milliseconds: 1000