Skip to content

Commit

Permalink
Cache plugins data. (#264)
Browse files Browse the repository at this point in the history
This includes attempts to speed up the workflow and limit the API calls to github by caching plugins data.

In preview.yml remove the fetch step and use the data that resides in gh-pages instead.
In ci.yml, the webpage created a cache for plugin data and restored it for each step.
Setup concurrency to the workflow.
  • Loading branch information
AhmedBasem20 authored Sep 1, 2023
1 parent 321f2e8 commit 03c525b
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 8 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ 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:
Expand Down Expand Up @@ -38,11 +44,30 @@ jobs:
run: pip install --upgrade wheel setuptools
- name: Install
run: pip install -e . -v

- 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: Cache plugins metadata
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/
Expand Down Expand Up @@ -78,7 +103,17 @@ jobs:
run: pip install --upgrade pip
- name: Install
run: pip install -e . -v
- 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
Expand Down
20 changes: 12 additions & 8 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ on:
- synchronize
- closed

concurrency: preview-${{ github.ref }}
# 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:
deploy-preview:
Expand All @@ -27,13 +31,13 @@ jobs:
run: pip install --upgrade wheel setuptools
- name: Install
run: pip install -e . -v
- name: fetch metadata
id: fetch_metadata
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: aiida-registry fetch
- name: Get entry points data
run: aiida-registry test-install
- name: Get cloned data from gh-pages
run: |
git remote set-url origin https://github.com/aiidateam/aiida-registry.git
git fetch origin gh-pages
git checkout origin/gh-pages plugins_metadata.json || true
- name: Move JSON file to the React project
run: |
mv plugins_metadata.json aiida-registry-app/src/
Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/webpage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ on:
branches:
- master

# 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:
webpage:
if: github.repository == 'aiidateam/aiida-registry'
Expand All @@ -36,11 +42,22 @@ jobs:
git fetch origin gh-pages
git checkout origin/gh-pages plugins_metadata.json || true
mv plugins_metadata.json cloned_plugins_metadata.json || true
- 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: Get entry points data
run: aiida-registry test-install
- name: Move the JSON file to the React directory
Expand Down

0 comments on commit 03c525b

Please sign in to comment.