Skip to content

Commit

Permalink
Merge pull request #610 from alphagov/configure-node
Browse files Browse the repository at this point in the history
Update GitHub Actions workflows with `.nvmrc`
  • Loading branch information
colinrotherham authored Dec 4, 2023
2 parents db6ccc7 + 4e9caf8 commit 92a1c72
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 61 deletions.
34 changes: 21 additions & 13 deletions .github/workflows/integration_tests.yaml
Original file line number Diff line number Diff line change
@@ -1,33 +1,41 @@
name: Integration tests

on: [push, pull_request]
on:
pull_request:

push:
branches:
- main

workflow_dispatch:

concurrency:
group: integration-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
test-saucelabs:
integration:
name: Build & test
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Read node version from .nvmrc
id: nvm
run: echo "##[set-output name=NVMRC;]$(cat .nvmrc)"
- name: Checkout code
uses: actions/[email protected]

- name: "Setup Node v${{ steps.nvm.outputs.NVMRC }}"
uses: actions/setup-node@v2
- name: Setup Node.js
uses: actions/setup-node@v4.0.0
with:
node-version: "${{ steps.nvm.outputs.NVMRC }}"
cache: 'npm'
cache: npm
check-latest: true
node-version-file: .nvmrc

- name: Install dependencies
run: npm ci

- name: Build
run: npm run build

- name: "Run integration tests"
- name: Run browser tests (without Sauce Labs)
run: npm run wdio:test
env:
SAUCE_ENABLED: "false" # ensure we don't use Sauce Labs
SAUCE_ENABLED: false
40 changes: 19 additions & 21 deletions .github/workflows/saucelabs.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
name: Cross-browser tests

# Our Sauce Labs account only allows 5 tests to run at a time.
concurrency: saucelabs

# Run for pull requests, or after changes to main branch, but not for any old
# branch, to limit number of workflows contending for Sauce Labs access.
on:
pull_request:

push:
branches:
- main
pull_request:

workflow_dispatch:

# Our Sauce Labs account only allows 5 tests to run at a time.
concurrency: saucelabs

jobs:
test-saucelabs:
saucelabs:
name: Build & test (with Sauce Labs)
runs-on: ubuntu-latest
timeout-minutes: 15
Expand All @@ -22,28 +22,26 @@ jobs:
if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}

steps:
- uses: actions/checkout@v2

- name: Read node version from .nvmrc
id: nvm
run: echo "##[set-output name=NVMRC;]$(cat .nvmrc)"
- name: Checkout code
uses: actions/[email protected]

- name: "Setup Node v${{ steps.nvm.outputs.NVMRC }}"
uses: actions/setup-node@v2
- name: Setup Node.js
uses: actions/setup-node@v4.0.0
with:
node-version: "${{ steps.nvm.outputs.NVMRC }}"
cache: 'npm'
cache: npm
check-latest: true
node-version-file: .nvmrc

- name: Install dependencies
run: npm ci

- name: Build
run: npm run build

- name: "Run cross-browser tests (using Sauce Labs)"
- name: Run browser tests (with Sauce Labs)
run: npm run wdio:test
env:
SAUCE_ENABLED: "true"
SAUCE_BUILD_NUMBER: "${{ github.run_id }}"
SAUCE_USERNAME: "${{ secrets.SAUCE_USERNAME }}"
SAUCE_ACCESS_KEY: "${{ secrets.SAUCE_ACCESS_KEY }}"
SAUCE_ENABLED: true
SAUCE_BUILD_NUMBER: ${{ github.run_id }}
SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
31 changes: 20 additions & 11 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
name: Test

on: [pull_request, push]
on:
pull_request:

push:
branches:
- main

workflow_dispatch:

concurrency:
group: tests-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
build:
test:
name: Build & basic tests
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Read node version from .nvmrc
id: nvm
run: echo "##[set-output name=NVMRC;]$(cat .nvmrc)"
- name: Checkout code
uses: actions/[email protected]

- name: "Setup Node v${{ steps.nvm.outputs.NVMRC }}"
uses: actions/setup-node@v2
- name: Setup Node.js
uses: actions/setup-node@v4.0.0
with:
node-version: "${{ steps.nvm.outputs.NVMRC }}"
cache: 'npm'
cache: npm
check-latest: true
node-version-file: .nvmrc

- name: Install dependencies
run: npm ci
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
14.18.2
lts/fermium
22 changes: 7 additions & 15 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,21 @@ If you want to help and want to get more familiar with the codebase, try startin

## Requirements

You will need a recent version of Node and npm installed:
You will need a recent version of Node and npm installed. Check the `.nvmrc` for a recommended version:

```bash
$ node -v
v7.10.0
v14.21.3
$ npm -v
v5.0.0
v6.14.18
```

If you want to run the selenium tests, you will also need a local copy of the Java Development Kit:
To install Node (with npm) locally on macOS, we recommend [brew](https://brew.sh) with
[nvm](https://github.com/nvm-sh/nvm):

```bash
$ java -version
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
```

To install Node (with npm) and Java locally on macOS, you can use [brew](https://brew.sh/):

```bash
brew install node
brew cask install java
brew install nvm
nvm install
```

## Project structure
Expand Down

0 comments on commit 92a1c72

Please sign in to comment.