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

feat: Reusable validator CI workflow #81

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
139 changes: 89 additions & 50 deletions .github/workflows/test-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,78 +8,113 @@ on:
workflow_dispatch:
repository_dispatch:
types: [data-models-update, data-model-validator-update, rpde-validator-update]
workflow_call:
inputs:
data-models_ref:
default: 'refs/heads/master'
required: false
type: string
data-model-validator_ref:
default: 'refs/heads/master'
required: false
type: string
rpde-validator_ref:
default: 'refs/heads/master'
required: false
type: string
data-model-validator-site_ref:
default: 'refs/heads/master'
required: false
type: string

jobs:
test-models:
test-site:
runs-on: ubuntu-latest
outputs:
lost-pixel-conclusion: ${{ steps.lp.conclusion }}
steps:
- name: Checkout validator
uses: actions/checkout@v2
with:
repository: openactive/data-models
- name: Use Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: 14
- name: Install

- name: Checkout data models
uses: actions/checkout@v4
with:
repository: openactive/data-models
ref: ${{ inputs.data-models_ref }}
path: data-models
- name: Install data models
run: npm install
- name: Test
working-directory: data-models
- name: Test data models
run: npm test
working-directory: data-models

test-data-model-validator:
runs-on: ubuntu-latest
steps:
- name: Checkout validator
uses: actions/checkout@v2
- name: Checkout model validator
uses: actions/checkout@v4
with:
repository: openactive/data-model-validator
- name: Use Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: 14
- name: Install
ref: ${{ inputs.data-model-validator_ref }}
path: data-model-validator
- name: Install data model validator
run: npm install
- name: Test
working-directory: data-model-validator
- name: Test data model validator
run: npm test
working-directory: data-model-validator

test-rpde-validator:
runs-on: ubuntu-latest
steps:
- name: Checkout validator
uses: actions/checkout@v2
- name: Checkout rpde validator
uses: actions/checkout@v4
with:
repository: openactive/rpde-validator
- name: Use Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: 14
- name: Install
ref: ${{ inputs.rpde-validator_ref }}
path: rpde-validator
- name: Install rpde validator
run: npm install
- name: Test
working-directory: rpde-validator
- name: Test rpde validator
run: npm test
working-directory: rpde-validator

test-site:
runs-on: ubuntu-latest
outputs:
lost-pixel-conclusion: ${{ steps.lp.conclusion }}
steps:
- name: Checkout validator site
uses: actions/checkout@v2
- name: Use Node.js 14.x
uses: actions/setup-node@v1
uses: actions/checkout@v4
with:
node-version: 14
- name: Install
repository: openactive/data-model-validator-site
ref: ${{ inputs.data-model-validator-site_ref || github.ref }}
path: data-model-validator-site
- name: Install validator site
run: npm install
- name: Test
working-directory: data-model-validator-site

- name: Update data-model-validator-site to reference local data-models
run: npm install file:../data-models
working-directory: data-model-validator-site

- name: Update data-model-validator-site to reference local data-model-validator
run: npm install file:../data-model-validator
working-directory: data-model-validator-site

- name: Update data-model-validator-site to reference local rpde-validator
run: npm install file:../rpde-validator
working-directory: data-model-validator-site

- name: Test validator site
run: npm test
working-directory: data-model-validator-site

- name: Start server (in background)
run: npm run start &
working-directory: data-model-validator-site

- name: Create alias for .lostpixel
run: ln -s ./data-model-validator-site/.lostpixel .lostpixel

- name: Check for unintentional UI changes with Lost Pixel
id: lp
uses: lost-pixel/lost-pixel@v3.16.0

uses: lost-pixel/lost-pixel@v3.22.0
env:
LOST_PIXEL_CONFIG_DIR: data-model-validator-site
- name: Upload Lost Pixel artefacts
uses: actions/upload-artifact@v3
if: ${{ failure() && steps.lp.conclusion == 'failure' }}
Expand All @@ -89,13 +124,16 @@ jobs:

create-pr-to-update-lost-pixel-baseline:
runs-on: ubuntu-latest
needs: [test-site, test-models, test-data-model-validator, test-rpde-validator]
needs: [test-site]
# Only run this job on branches other than master; this is to prevent the Lost Pixel baseline from being updated on the master branch.
# The baseline should only be updated on PRs, not on the master branch.
if: ${{ failure() && github.ref != 'refs/heads/master' && needs.test-site.outputs.lost-pixel-conclusion == 'failure'}}
if: ${{ github.repository == 'openactive/data-model-validator-site' && failure() && github.ref != 'refs/heads/master' && needs.test-site.outputs.lost-pixel-conclusion == 'failure'}}
steps:
- name: Checkout validator site
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
- name: Use Node.js 14.x
uses: actions/setup-node@v1
with:
Expand All @@ -108,7 +146,8 @@ jobs:
run: npm run start &

- name: Lost Pixel
uses: lost-pixel/lost-pixel@v3.16.0
continue-on-error: true
uses: lost-pixel/lost-pixel@v3.22.0
env:
LOST_PIXEL_MODE: update

Expand Down Expand Up @@ -140,8 +179,8 @@ jobs:
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"

deploy-site:
needs: [test-site, test-models, test-data-model-validator, test-rpde-validator]
if: ${{ github.ref == 'refs/heads/master' }}
needs: [test-site]
if: ${{ github.repository == 'openactive/data-model-validator-site' && github.ref == 'refs/heads/master' }}
concurrency:
group: validator-staging.openactive.io
cancel-in-progress: true
Expand Down Expand Up @@ -171,7 +210,7 @@ jobs:

- name: Smoke test with Lost Pixel
id: lp
uses: lost-pixel/lost-pixel@v3.16.0
uses: lost-pixel/lost-pixel@v3.22.0
env:
LOST_PIXEL_BASE_URL: https://validator-staging.openactive.io

Expand All @@ -184,7 +223,7 @@ jobs:

promote-site:
needs: deploy-site
if: ${{ github.ref == 'refs/heads/master' }}
if: ${{ github.repository == 'openactive/data-model-validator-site' && github.ref == 'refs/heads/master' }}
concurrency:
group: validator.openactive.io
cancel-in-progress: true
Expand Down
Binary file modified .lostpixel/baseline/model-validator-home.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .lostpixel/baseline/rpde-validator-home.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .lostpixel/baseline/scheduledsession.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .lostpixel/baseline/sessionseries.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
"jasmine": "^3.2.0",
"jasmine-enzyme": "^6.1.2",
"jsdom": "^11.12.0",
"lost-pixel": "^3.18.2",
"lost-pixel": "^3.22.0",
"nodemon": "^1.18.4",
"sass": "^1.49.9",
"sass-loader": "^7.2.0",
Expand Down
Loading