-
Notifications
You must be signed in to change notification settings - Fork 67
133 lines (117 loc) · 3.54 KB
/
plugin-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
name: Plugin CI
on:
pull_request_target:
types:
- opened
- synchronize
- ready_for_review
- reopened
paths:
- "plugins.yaml"
branches:
- master
# For development, use the following instead:
# on: [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:
get-pr:
# https://dev.to/suzukishunsuke/secure-github-actions-by-pullrequesttarget-641
outputs:
merge_commit_sha: ${{steps.pr.outputs.merge_commit_sha}}
runs-on: ubuntu-latest
steps:
- uses: suzuki-shunsuke/[email protected]
id: pr
test-utils:
runs-on: ubuntu-latest
needs:
- get-pr
steps:
- name: Checkout Repo ⚡️
uses: actions/checkout@v4
with:
ref: ${{needs.get-pr.outputs.merge_commit_sha}}
- 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
needs:
- get-pr
steps:
# 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
- name: Checkout Repo ⚡️
uses: actions/checkout@v4
with:
ref: ${{needs.get-pr.outputs.merge_commit_sha}}
- name: Create dev environment
uses: ./.github/actions/create-dev-env
- name: Generate metadata
uses: ./.github/actions/generate-metadata
with:
gh_token: ${{ secrets.GITHUB_TOKEN }}
cache: true
- 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
preview:
# This job is triggered by (only) a PR.
needs: [test-webpage-build, get-pr]
runs-on: ubuntu-latest
strategy:
fail-fast: false
timeout-minutes: 180
env:
COMMIT_AUTHOR: Deploy Action
COMMIT_AUTHOR_EMAIL: [email protected]
VITE_PR_PREVIEW_PATH: "/aiida-registry/pr-preview/pr-${{ github.event.number }}/"
steps:
- name: Checkout Repo ⚡️
uses: actions/checkout@v4
with:
ref: ${{needs.get-pr.outputs.merge_commit_sha}}
- name: Create dev environment
uses: ./.github/actions/create-dev-env
- name: Generate metadata
uses: ./.github/actions/generate-metadata
with:
gh_token: ${{ secrets.GITHUB_TOKEN }}
cache: false
- uses: actions/setup-node@v3
with:
node-version: '18.x'
- name: Install npm dependencies and build
run: |
echo $VITE_PR_PREVIEW_PATH
npm install
npm run build
working-directory: ./aiida-registry-app
- name: Add plugins file to the build folder
run: cp plugins_metadata.json aiida-registry-app/dist/
- name: Deploy preview
uses: rossjrw/pr-preview-action@v1
with:
source-dir: ./aiida-registry-app/dist
preview-branch: gh-pages
umbrella-dir: pr-preview
action: auto
custom-url:
token: ${{ secrets.BOT_COMMENT_TOKEN }} # use aiida-bot token to deploy the preview