Use reusable actions and refact CI workflow #628
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: [push, pull_request] | |
# https://docs.github.com/en/actions/using-jobs/using-concurrency | |
concurrency: | |
# only cancel in-progress jobs or runs for the current workflow - matches against branch & tags | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
pre-commit: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repo ⚡️ | |
uses: actions/checkout@v3 | |
- name: Create dev environment | |
uses: ./.github/actions/create-dev-env | |
- name: Run pre-commit | |
run: | |
pre-commit run --all-files || ( git status --short ; git diff ; exit 1 ) | |
test-utils: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repo ⚡️ | |
uses: actions/checkout@v3 | |
- name: Create dev environment | |
uses: ./.github/actions/create-dev-env | |
- name: Run tests | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: pytest tests/ | |
test-webpage-build: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
timeout-minutes: 30 | |
# This is a CI job that checks if the webpage can be built | |
# We use the plugins metadata from caching since we don't want to | |
# fetch it twice and it is not essential for this job to have | |
# the latest generated metadata | |
steps: | |
- name: Checkout Repo ⚡️ | |
uses: actions/checkout@v3 | |
- name: Create dev environment | |
uses: ./.github/actions/create-dev-env | |
- name: Restore cached Plugins | |
id: cache-plugins-restore | |
uses: actions/cache/restore@v3 | |
with: | |
path: plugins_metadata.json | |
key: plugins_metadata | |
- name: fetch metadata | |
if: steps.cache-plugins-restore.outputs.cache-hit != 'true' | |
id: fetch_metadata | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: aiida-registry fetch | |
#- name: Check plugins installation | |
# # This step will attach plugin installation inforamtion to the metadata, e.g. if the plugin can be installed or not | |
# run: aiida-registry test-install | |
- name: Cache plugins metadata | |
if: steps.cache-plugins-restore.outputs.cache-hit != 'true' | |
id: cache-plugins-save | |
uses: actions/cache/save@v3 | |
with: | |
path: plugins_metadata.json | |
key: ${{ steps.cache-plugins-restore.outputs.cache-primary-key }} | |
- name: Move JSON file to the React project | |
run: mv plugins_metadata.json aiida-registry-app/src/ | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: '18.x' | |
- name: Install npm dependencies and build | |
run: | | |
npm install | |
npm run build | |
working-directory: ./aiida-registry-app |