-
Notifications
You must be signed in to change notification settings - Fork 1
164 lines (140 loc) · 5.46 KB
/
pr_develop.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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File: pr_develop.yml
# Date: 2024-08-13
# ---------------------------------------------------------------------------- #
# Workflow Overview
# ---------------------------------------------------------------------------- #
# This file contains the workflow that checks PRs for the develop branch. It
# checks for linting, formatting, and compilation. The workflow is triggered
# when a PR is opened, synchronized, reopened, or ready for review.
# The workflow is split into multiple jobs:
# - Prepare: Checks if the PR is a draft and stores global environment variables.
# - Linting: Lints the PR for any changes.
# - Formatting: Formats the PR for any changes.
# - Compilation: Compiles the PR for any changes.
# - Complete: Checks if all previous jobs passed.
# The jobs are run in a sequence, where the Prepare job is run first. The Linting,
# Formatting, and Compilation jobs run in parallel, and the Complete job runs last.
# The workflow uses the following environment variables:
# - FLINT_GLOBAL_MINIMUM: The minimum global linting score.
# - FLINT_CHANGED_FILES_MINIMUM: The minimum linting score for changed files.
# - PFUNIT_VERSION: The version of pFUnit to use.
# - JSON_FORTRAN_VERSION: The version of JSON-Fortran to use.
# - NEKO_VERSION: The version of Neko to use.
name: Develop PR Checks
on:
pull_request:
branches: [develop]
types:
- opened
- synchronize
- reopened
- ready_for_review
merge_group:
types: [checks_requested]
# ---------------------------------------------------------------------------- #
# Define the global environment variables, these control versioning and other
# useful settings in a unified way. Due to limitations in the GitHub Actions
# environment, we cannot pass these as inputs to the jobs, so the prepare job
# will store them in a file that the other jobs can read.
env:
PFUNIT_VERSION: main
JSON_FORTRAN_VERSION: master
NEKO_VERSION: develop
# ---------------------------------------------------------------------------- #
# Allow only one concurrent deployment, skipping runs queued between the run
# in-progress and latest queued. We do not wish to waste time on old runs if a
# newer one is available.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
# ---------------------------------------------------------------------------- #
# Define the jobs that will be run in this workflow. The jobs are run in a
# sequence, where the Prepare job is run first. The Linting, Formatting, and
# Compilation jobs run in parallel, and the Complete job runs last.
jobs:
prepare:
name: Prepare the environment
runs-on: ubuntu-latest
outputs:
pfunit-version: ${{ steps.store.outputs.pfunit-version }}
json-fortran-version: ${{ steps.store.outputs.json-fortran-version }}
neko-version: ${{ steps.store.outputs.neko-version }}
steps:
- name: Check if PR is a draft
shell: bash
run: |
if [ "${{ github.event.pull_request.draft }}" == "true" ]; then
echo "PR is a draft" >&2
exit 1
fi
- name: Store environment variables
id: store
run: |
echo "pfunit-version=$PFUNIT_VERSION" >> $GITHUB_OUTPUT
echo "json-fortran-version=$JSON_FORTRAN_VERSION" >> $GITHUB_OUTPUT
echo "neko-version=$NEKO_VERSION" >> $GITHUB_OUTPUT
check_lint:
name: Linting
needs:
- prepare
uses: ./.github/workflows/check_lint.yml
check_format:
name: Formatting
needs:
- prepare
uses: ./.github/workflows/check_formatting.yml
check_neko-top:
name: Neko-TOP Library
needs:
- prepare
uses: ./.github/workflows/check_neko-top.yml
with:
neko-version: ${{ needs.prepare.outputs.neko-version }}
pfunit-version: ${{ needs.prepare.outputs.pfunit-version }}
json-fortran-version: ${{ needs.prepare.outputs.json-fortran-version }}
# -------------------------------------------------------------------------- #
# Check if all previous jobs passed. If any of the previous jobs failed, the
# Complete job will fail and print out the failed jobs.
check_complete:
if: ${{ always() }}
name: Develop PR Ready
needs:
- prepare
- check_lint
- check_format
- check_neko-top
runs-on: ubuntu-latest
env:
draft_status: ${{ needs.prepare.result }}
flint_status: ${{ needs.check_lint.result }}
format_status: ${{ needs.check_format.result }}
compile_status: ${{ needs.check_neko-top.result }}
steps:
- name: Check status of previous jobs
run: |
success=true
fail=()
if [ "$draft_status" != "success" ]; then
fail+=("\t- Draft check: $draft_status")
success=false
fi
if [ "$flint_status" != "success" ]; then
fail+=("\t- Linting check: $flint_status")
success=false
fi
if [ "$format_status" != "success" ]; then
fail+=("\t- Formatting check: $format_status")
success=false
fi
if [ "$compile_status" != "success" ]; then
fail+=("\t- Compilation check: $compile_status")
success=false
fi
if [ "$success" == false ]; then
>&2 echo "The following checks did not succeed:"
for i in "${fail[@]}"; do
>&2 printf "$i\n"
done
exit 1
fi
echo "All checks passed"