-
Notifications
You must be signed in to change notification settings - Fork 1
142 lines (115 loc) · 4.1 KB
/
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
134
135
136
137
138
139
140
141
142
name: CI
on:
push:
branches-ignore: gh-pages
pull_request:
branches-ignore: gh-pages
concurrency: ci-${{ github.ref }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: "recursive"
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
distribution: zulu
java-version: 17
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew assemble --no-daemon --no-watch-fs
- name: Run the tests
run: ./gradlew check --no-daemon --no-watch-fs
- name: Build application distribution
run: ./gradlew installDist --no-daemon --no-watch-fs
- name: Upload application distribution
uses: actions/upload-artifact@v3
with:
name: assessor_dist
path: build/install/assessor
reports_generate:
needs: build
runs-on: ubuntu-latest
steps:
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
distribution: zulu
java-version: 17
- name: Fetch distribution
uses: actions/[email protected]
with:
name: assessor_dist
path: dist
- name: Generate reports
run: |
chmod +x dist/bin/assessor
dist/bin/assessor all --long --dir reports
dist/bin/assessor all --json --dir reports/json
dist/bin/assessor all --proposals --dir reports/proposal
dist/bin/assessor all --statistics --dir reports/statistics
- name: Generate index.md
run: |
REPORTS_DIR=reports
shopt -s nullglob
REPORTS=("$REPORTS_DIR"/*.txt)
IFS=$'\n' REPORTS=($(sort -n -r -t $'-' -k 1 <<<"${REPORTS[*]}"))
unset IFS
LATEST_REPORT_DEST="$REPORTS_DIR/latest.txt"
INDEX_FILE="$REPORTS_DIR/index.md"
touch $INDEX_FILE
echo "Reports: ${REPORTS[*]}"
echo "# Assessor's Archive" >> $INDEX_FILE
echo "" >> $INDEX_FILE
echo "[Latest Assessment]($(basename "${REPORTS[0]}"))" >> $INDEX_FILE
echo "" >> $INDEX_FILE
echo "List of assessments:" >> $INDEX_FILE
echo "" >> $INDEX_FILE
for report in "${REPORTS[@]}"; do
REPORT_FILENAME=$(basename "$report")
echo "* [$REPORT_FILENAME]($REPORT_FILENAME)" >> $INDEX_FILE;
done;
cp -- "${REPORTS[0]}" "$LATEST_REPORT_DEST"
- name: Upload reports artifacts
uses: actions/upload-artifact@v2
with:
name: reports
path: reports
reports_deploy:
if: github.ref == 'refs/heads/main'
needs: reports_generate
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: "recursive"
- name: Fetch reports artifact
uses: actions/[email protected]
with:
name: reports
path: artifacts/reports
- name: Copy reports to gh-pages dir
run: "cp -R artifacts/reports/* generation/gh-pages"
- name: Deploy reports to Github Pages
run: |
# Set Git committer identity
git config user.name "ci-build"
git config user.email "[email protected]"
# Clear the index
EMPTY_TREE="$(git hash-object -t tree /dev/null)"
git read-tree -- "$EMPTY_TREE"
# Add site data to index
git add generation/gh-pages
git fetch origin gh-pages
ORIG_SITE_TREE="$(git rev-parse origin/gh-pages^{tree})"
NEW_SITE_TREE="$(git write-tree --prefix=generation/gh-pages)"
if [ "$ORIG_SITE_TREE" != "$NEW_SITE_TREE" ]; then
SITE_COMMIT="$(git commit-tree -p origin/gh-pages -m "[skip ci] CI Updates" -- "$NEW_SITE_TREE")"
echo Updating GitHub pages site to commit "$SITE_COMMIT"
git push origin "$SITE_COMMIT":gh-pages
else
echo Not updating GitHub pages site
fi