Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add publishing workflow; update workflow, dependencies, tasks, docs #147

Merged
merged 44 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
610fd6c
Add publishing workflow
danyalaytekin Oct 26, 2023
327b548
Always run linter
danyalaytekin Oct 26, 2023
1e24f29
Use `npm ci` instead of `npm i`
danyalaytekin Oct 26, 2023
99319ff
Reformat YAML
danyalaytekin Oct 26, 2023
b4f6468
Increase `INTEGRATION_TIMEOUT` to `20000` from `5000`
danyalaytekin Nov 3, 2023
6eb3db4
Remove outdated makefile items
danyalaytekin Nov 3, 2023
9a741ac
Update to `eslint@^8.52` and `pa11y-lint-config@^3`
danyalaytekin Nov 7, 2023
d2e3081
Replace the warning about Node.js 16, since it's passing in the workflow
danyalaytekin Nov 7, 2023
9ffabf4
Lower-case headings to match `pa11y/pa11y`, use backticks for config …
danyalaytekin Nov 7, 2023
9ba2311
Update copyright date to 2023
danyalaytekin Nov 7, 2023
f0dbd6f
Apply agreed support policy; tighten up Node.js versions
danyalaytekin Nov 7, 2023
1ce2fdd
Upgrade to `joi@~17.11`
danyalaytekin Nov 7, 2023
268d148
Rename workflow from `checkout_and_test` to `test`, matching other repos
danyalaytekin Nov 7, 2023
c0449c8
Shorten the matrix of Node.js versions
danyalaytekin Nov 7, 2023
27073d4
Improve the comments that remain
danyalaytekin Nov 7, 2023
2c08ffc
Upgrade to `cron@~2.4.4`
danyalaytekin Nov 7, 2023
cf9a922
Point the build badge to GitHub Actions, replacing Travis
danyalaytekin Nov 7, 2023
66eed1d
Consistently use single quotes
danyalaytekin Nov 7, 2023
675056b
Require presence of test folders and remove generalised items
danyalaytekin Nov 7, 2023
743760f
Settle on `make lint` throughout rather than the combination of `veri…
danyalaytekin Nov 7, 2023
6a8b9a0
Split testing in workflow; move unit tests before service boot
danyalaytekin Nov 7, 2023
0f5d946
Embed vars since they're already documented, narrow headings
danyalaytekin Nov 7, 2023
c881189
Exit with an error when webservice isn't running
danyalaytekin Nov 7, 2023
04e239e
Clarify relationship between tests and service in contribution section
danyalaytekin Nov 7, 2023
a29a53d
Reorganise requirements and introduction's advice about options
danyalaytekin Nov 7, 2023
8cddd1e
Integrate regions discussing configuration and reorganise
danyalaytekin Nov 7, 2023
7175c6d
Remove unused link definitions
danyalaytekin Nov 7, 2023
eeffaf3
Publish with minimum supported Node.js version (12)
danyalaytekin Nov 7, 2023
1ea8f61
Move MongoDB action adjacent to remainder of integration test setup t…
danyalaytekin Nov 7, 2023
fd66831
Fix copyright newline
danyalaytekin Nov 7, 2023
b472018
Make requirements clearer
danyalaytekin Nov 7, 2023
c9fe57f
Fix tone in introduction after revision
danyalaytekin Nov 7, 2023
37188d8
Emphasise headless chrome config exclusivity
danyalaytekin Nov 7, 2023
5a9ab33
Link to config dir, be clearer about modes, separate scripts
danyalaytekin Nov 7, 2023
69288b5
Fix weird environment var section after revision
danyalaytekin Nov 7, 2023
81a87c8
Shorten options descriptions
danyalaytekin Nov 7, 2023
ff9d8cd
Link to fixtures
danyalaytekin Nov 7, 2023
2d6018b
Fix link to list of configuration options
danyalaytekin Nov 7, 2023
ba5b554
Use normal weight for requirements links
danyalaytekin Nov 7, 2023
682a452
Make first line sound better
danyalaytekin Nov 7, 2023
cc924cd
Improve introduction to `#configuration`
danyalaytekin Nov 7, 2023
697713a
Change 'Pa11y 4` to `Pa11y Webservice 4`
danyalaytekin Nov 7, 2023
887a948
Remove unused task `make all`
danyalaytekin Nov 7, 2023
35393f5
Remove make's install tasks since we use `npm install` and `npm ci` i…
danyalaytekin Nov 7, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
on:
release:
types: [created, edited, published]
workflow_dispatch:
inputs:
dryRun:
description: 'Dry run only'
required: true
default: true
type: boolean

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: 12
registry-url: 'https://registry.npmjs.org'
- run: npm ci

- name: Publish package
env:
NODE_AUTH_TOKEN: ${{ secrets.REGISTRY_PUBLISH_TOKEN }}
if: >
(github.event_name == 'release' && github.event.action == 'published') ||
(github.event_name == 'workflow_dispatch' && !inputs.dryRun)
run: npm publish

- name: Publish package (dry run)
env:
NODE_AUTH_TOKEN: ${{ secrets.REGISTRY_PUBLISH_TOKEN }}
if: >
(github.event_name == 'release' && github.event.action != 'published') ||
(github.event_name == 'workflow_dispatch' && inputs.dryRun)
run: npm publish --dry-run
41 changes: 14 additions & 27 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,32 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests.
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Build and lint

on:
push:
branches:
- main
pull_request:

jobs:
checkout_and_test:
test:
runs-on: ubuntu-20.04
strategy:
matrix:
include:
- node-version: 12.x
lint: true # Linter is run only once to shorten the total build time
- node-version: 14.x
- node-version: 16.x

node-version: [12, 14, 16]
steps:
- name: Checkout code from ${{ github.repository }}
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: MongoDB in GitHub Actions
- run: npm ci
- run: make lint
- run: make test-unit

- name: Supply MongoDB 3.4
uses: supercharge/[email protected]
with:
mongodb-version: 3.4
- name: Install dependencies
run: npm ci
- name: Run linter
if: ${{ matrix.lint }}
run: make lint
- name: Create test config
mongodb-version: 3.4
- name: Supply integration test configuration file
run: cp config/test.sample.json config/test.json
- name: Start test app
- name: Make webservice available to be integration-tested
run: NODE_ENV=test node index.js &
- run: sleep 10s
- name: Run tests
run: make test

- run: make test-integration
13 changes: 1 addition & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
include Makefile.node


# Verify tasks
# ------------

# Lint alias for backwards compatibility
lint: verify


# Database tasks
# --------------

# Add fixtures
# Add fixtures to database
fixtures:
@node ./script/fixtures.js
@$(TASK_DONE)
117 changes: 12 additions & 105 deletions Makefile.node
Original file line number Diff line number Diff line change
@@ -1,28 +1,13 @@
#
# Node.js Makefile
# ================
#
# Do not update this file manually – it's maintained separately on GitHub:
# https://github.com/rowanmanning/makefiles/blob/master/Makefile.node
#
# To update to the latest version, run `make update-makefile`.
#


# Meta tasks
# ----------
# Ignore presence of folder `test`
# --------------------------------

.PHONY: test


# Useful variables
# ----------------
# Make deps available
# -------------------

NPM_BIN = ./node_modules/.bin
export PATH := $(NPM_BIN):$(PATH)
export EXPECTED_COVERAGE := 90
export INTEGRATION_TIMEOUT := 5000
export INTEGRATION_SLOW := 4000
export PATH := ./node_modules/.bin:$(PATH)


# Output helpers
Expand All @@ -31,95 +16,17 @@ export INTEGRATION_SLOW := 4000
TASK_DONE = echo "✓ $@ done"


# Group tasks
# -----------

all: install ci
ci: verify test


# Install tasks
# -------------

clean:
@git clean -fxd
@$(TASK_DONE)

install: node_modules
@$(TASK_DONE)

node_modules: package.json
@npm prune --production=false
@npm install
@$(TASK_DONE)


# Verify tasks
# ------------

verify: verify-javascript verify-dust verify-spaces
@$(TASK_DONE)

verify-javascript: verify-eslint verify-jshint verify-jscs
@$(TASK_DONE)

verify-dust:
@if [ -e .dustmiterc* ]; then dustmite --path ./view && $(TASK_DONE); fi

verify-eslint:
@if [ -e .eslintrc* ]; then eslint . && $(TASK_DONE); fi

verify-jshint:
@if [ -e .jshintrc* ]; then jshint . && $(TASK_DONE); fi

verify-jscs:
@if [ -e .jscsrc* ]; then jscs . && $(TASK_DONE); fi
# Linting and testing
# -------------------

verify-spaces:
@if [ -e .editorconfig* ] && [ -x $(NPM_BIN)/lintspaces ]; then \
git ls-files | xargs lintspaces -e .editorconfig && $(TASK_DONE); \
fi
lint:
@eslint . && $(TASK_DONE)

verify-coverage:
@if [ -d coverage ]; then \
if [ -x $(NPM_BIN)/nyc ]; then \
nyc check-coverage --lines $(EXPECTED_COVERAGE) --functions $(EXPECTED_COVERAGE) --branches $(EXPECTED_COVERAGE) && $(TASK_DONE); \
else \
if [ -x $(NPM_BIN)/istanbul ]; then \
istanbul check-coverage --statement $(EXPECTED_COVERAGE) --branch $(EXPECTED_COVERAGE) --function $(EXPECTED_COVERAGE) && $(TASK_DONE); \
fi \
fi \
fi

# Test tasks
# ----------

test: test-unit-coverage verify-coverage test-integration
test: test-unit test-integration
@$(TASK_DONE)

test-unit:
@if [ -d test/unit ]; then mocha test/unit --exit --recursive && $(TASK_DONE); fi

test-unit-coverage:
@if [ -d test/unit ]; then \
if [ -x $(NPM_BIN)/nyc ]; then \
nyc --reporter=text --reporter=html $(NPM_BIN)/_mocha test/unit --exit --recursive && $(TASK_DONE); \
else \
if [ -x $(NPM_BIN)/istanbul ]; then \
istanbul cover $(NPM_BIN)/_mocha -- test/unit --exit --recursive && $(TASK_DONE); \
else \
make test-unit; \
fi \
fi \
fi
@mocha test/unit --exit --recursive && $(TASK_DONE)

test-integration:
@if [ -d test/integration ]; then mocha test/integration --exit --timeout $(INTEGRATION_TIMEOUT) --slow $(INTEGRATION_SLOW) && $(TASK_DONE); fi


# Tooling tasks
# -------------

update-makefile:
@curl -s https://raw.githubusercontent.com/rowanmanning/makefiles/master/Makefile.node > Makefile.node
@$(TASK_DONE)
@mocha test/integration --exit --timeout 20000 --slow 4000 && $(TASK_DONE)
Loading
Loading