Skip to content

Commit

Permalink
Add publishing workflow; update workflow, dependencies, tasks, docs (#…
Browse files Browse the repository at this point in the history
…147)

* Add publishing workflow

* Always run linter

* Use `npm ci` instead of `npm i`

* Reformat YAML

* Increase `INTEGRATION_TIMEOUT` to `20000` from `5000`

* Remove outdated makefile items

* Update to `eslint@^8.52` and `pa11y-lint-config@^3`

* Replace the warning about Node.js 16, since it's passing in the workflow

* Lower-case headings to match `pa11y/pa11y`, use backticks for config options

* Update copyright date to 2023

* Apply agreed support policy; tighten up Node.js versions

* Upgrade to `joi@~17.11`

* Rename workflow from `checkout_and_test` to `test`, matching other repos

* Shorten the matrix of Node.js versions

* Improve the comments that remain

* Upgrade to `cron@~2.4.4`

* Point the build badge to GitHub Actions, replacing Travis

* Consistently use single quotes

* Require presence of test folders and remove generalised items

* Settle on `make lint` throughout rather than the combination of `verify` and `lint`

* Split testing in workflow; move unit tests before service boot

* Embed vars since they're already documented, narrow headings

* Exit with an error when webservice isn't running

* Clarify relationship between tests and service in contribution section

* Reorganise requirements and introduction's advice about options

* Integrate regions discussing configuration and reorganise

* Remove unused link definitions

* Publish with minimum supported Node.js version (12)

* Move MongoDB action adjacent to remainder of integration test setup to allow early failures

* Fix copyright newline

* Make requirements clearer

* Fix tone in introduction after revision

* Emphasise headless chrome config exclusivity

* Link to config dir, be clearer about modes, separate scripts

* Fix weird environment var section after revision

* Shorten options descriptions

* Link to fixtures

* Fix link to list of configuration options

* Use normal weight for requirements links

* Make first line sound better

* Improve introduction to `#configuration`

* Change 'Pa11y 4` to `Pa11y Webservice 4`

* Remove unused task `make all`

* Remove make's install tasks since we use `npm install` and `npm ci` in the readme and CI
  • Loading branch information
danyalaytekin authored Nov 7, 2023
1 parent eb1ae50 commit 59bf0f9
Show file tree
Hide file tree
Showing 8 changed files with 444 additions and 636 deletions.
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

0 comments on commit 59bf0f9

Please sign in to comment.