-
Notifications
You must be signed in to change notification settings - Fork 5
235 lines (231 loc) · 8.41 KB
/
main.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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
---
name: main
on:
push:
pull_request:
workflow_dispatch:
schedule:
- cron: "0 6 * * *"
defaults:
run:
shell: bash
env:
# dotnet
rdmp-cli-dir: "./rdmp-cli"
db-password: "YourStrongPassw0rd"
# java
java-version: 11
java-distribution: temurin
# python
python-version: 3.6
jobs:
init:
runs-on: ubuntu-20.04
outputs:
matrix: ${{ steps.matrix.outputs.matrix }}
build_ref: ${{ steps.build_ref.outputs.build_ref }}
steps:
- name: checkout
uses: actions/checkout@v3
- name: set matrix
id: matrix
run: |
set -euxo pipefail
matrix="$(jq --compact-output . .github/workflows/envs.json)"
echo $matrix
echo "matrix=$matrix" >> $GITHUB_OUTPUT
- name: set build ref
id: build_ref
run: |
set -euxo pipefail
build_ref="$GITHUB_REF_NAME"
[ "$GITHUB_REF_TYPE" != "tag" ] && build_ref="${GITHUB_SHA:0:6}"
echo "build_ref=$build_ref" >> $GITHUB_OUTPUT
smi:
needs: [init]
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.init.outputs.matrix) }}
runs-on: ${{ matrix.image }}
steps:
- name: "[linux] enable disk caching"
if: ${{ matrix.os == 'linux' }}
run: sudo apt-get install -y libeatmydata1
- name: checkout
uses: actions/checkout@v3
- name: "[windows] start MongoDB service"
if: ${{ matrix.os == 'windows' }}
shell: pwsh
run: |
reg.exe add HKLM\System\CurrentControlSet\Control /v ServicesPipeTimeout /t REG_DWORD /d 300000 /f
sc.exe config MongoDB start= auto
sc.exe start MongoDB
- name: setup .NET
# NOTE(rkm 2022-02-20) Uses global.json
uses: actions/[email protected]
- name: download tessdata
run: ./bin/smi/downloadTessdata.py
- name: "[linux] start services"
if: ${{ matrix.os == 'linux' }}
run: ./bin/smi/startDockerLinux.py ${{ env.db-password }}
- name: "[linux] re-write database strings"
if: ${{ matrix.os == 'linux' }}
run: |
set -euxo pipefail
echo "rdmp_conn_str=localhost -u sa -p ${{ env.db-password }}" >> $GITHUB_ENV
./bin/smi/writeDatabaseStrings.py localhost "${{ env.db-password }}"
- name: set RDMP version
run: |
set -euxo pipefail
rdmp_cli_ver=$(grep -F -m1 HIC.RDMP.Plugin Directory.Packages.props | sed -n 's/.*Version="\([0-9.]*\)".*/\1/p')
echo "rdmp_cli_ver=$rdmp_cli_ver" >> $GITHUB_ENV
- name: "[windows] Install SQL LocalDB"
if: ${{ matrix.os == 'windows' }}
uses: crazy-max/ghaction-chocolatey@v2
with:
args: install sqllocaldb
- name: "[windows] Check SQL LocalDB and set rdmp_conn_str"
if: ${{ matrix.os == 'windows' }}
shell: pwsh
run: |
Write-Host "Checking"
$db = "(localdb)\MSSQLLocalDB"
SqlLocalDB.exe create MSSQLLocalDB -s
sqlcmd -l 180 -S "$db" -Q "SELECT @@VERSION;"
echo "rdmp_conn_str='$db'" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
- name: "[windows] re-write database strings"
if: ${{ matrix.os == 'windows' }}
run: ./bin/smi/writeDatabaseStrings.py "(localdb)\MSSQLLocalDB" "${{ env.db-password }}"
- name: download rdmp-cli
if: ${{ matrix.os == 'windows' }}
run: ./bin/smi/downloadRdmpCli.py ${{ env.rdmp_cli_ver }}
- name: download rdmp-cli
if: ${{ matrix.os == 'linux' }}
run: |
curl -L https://github.com/HicServices/RDMP/releases/download/v${{ env.rdmp_cli_ver }}/rdmp-${{ env.rdmp_cli_ver }}-cli-linux-x64.tar.xz | tar xJf -
mv rdmp-${{ env.rdmp_cli_ver }}-cli-linux rdmp-cli
- name: install RDMP databases
run: ${{ env.rdmp-cli-dir }}/rdmp install --createdatabasetimeout 180 ${{ env.rdmp_conn_str }} TEST_
- name: show dotnet info
run: dotnet --info
- name: build, test, and package dotnet
run: |
set -euxo pipefail
cov=""
[ "${{ matrix.os }}" == "windows" ] && cov="--no-coverage"
./bin/smi/buildTestPackage.py \
${{ needs.init.outputs.build_ref }} \
"$cov"
- name: upload coverage
if: ${{ matrix.os == 'linux' }}
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage/coverage.cobertura.xml
fail_ci_if_error: true
- name: upload dist
uses: actions/upload-artifact@v3
with:
name: SmiServices-${{ needs.init.outputs.build_ref }}.zip
path: dist/${{ needs.init.outputs.build_ref }}/*
if-no-files-found: error
ctp:
needs: [init]
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.init.outputs.matrix) }}
runs-on: ${{ matrix.image }}
steps:
- name: "[linux] enable disk caching"
if: ${{ matrix.os == 'linux' }}
run: sudo apt-get install -y libeatmydata1
- name: checkout
uses: actions/checkout@v3
- name: Setup Java JDK
uses: actions/[email protected]
with:
java-version: ${{ env.java-version }}
distribution: ${{ env.java-distribution }}
cache: maven
- name: "[linux] start services"
if: ${{ matrix.os == 'linux' }}
run: ./bin/ctp/startDockerLinux.py
- name: "[windows] skip integration tests"
if: ${{ matrix.os == 'windows' }}
run: echo "JAVA_TESTS=--skip-integration-tests" >> $GITHUB_ENV
- name: build, test, and package ctp
run: ./bin/ctp/buildTestPackage.py --install-libs ${{ needs.init.outputs.build_ref }} ${{ env.JAVA_TESTS }}
- name: "[linux] upload packages"
if: ${{ matrix.os == 'linux' }}
uses: actions/upload-artifact@v3
with:
name: SmiServices-${{ needs.init.outputs.build_ref }}.zip
path: dist/${{ needs.init.outputs.build_ref }}/*
if-no-files-found: error
smi-py:
needs: [init]
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.init.outputs.matrix) }}
runs-on: ${{ matrix.image }}
steps:
- name: "[linux] enable disk caching"
if: ${{ matrix.os == 'linux' }}
run: sudo apt-get install -y libeatmydata1
- name: checkout
uses: actions/checkout@v3
- name: setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.python-version }}
- name: create venv
run: |
set -exuo pipefail
python -m pip install --upgrade virtualenv
python -m virtualenv venv
echo "venv_bin=./venv/bin" >> $GITHUB_ENV
- name: "[windows] update venv var"
if: ${{ matrix.os == 'windows' }}
run: echo "venv_bin=./venv/Scripts" >> $GITHUB_ENV
- name: test and package python
run: ./bin/smi-py/testPackage.py ${{ needs.init.outputs.build_ref }} ${{ env.venv_bin }}/python
- name: "[linux] upload packages"
if: ${{ matrix.os == 'linux' }}
uses: actions/upload-artifact@v3
with:
name: SmiServices-${{ needs.init.outputs.build_ref }}.zip
path: dist/${{ needs.init.outputs.build_ref }}/*
if-no-files-found: error
upload-to-release:
if: contains(github.ref, 'refs/tags/v')
needs: [init, smi, ctp, smi-py]
runs-on: ubuntu-20.04
steps:
- name: "[linux] enable disk caching"
if: ${{ matrix.os == 'linux' }}
run: sudo apt-get install -y libeatmydata1
- name: checkout
uses: actions/checkout@v3
- name: download artifacts
uses: actions/download-artifact@v3
with:
path: ./dist
- name: prepare artifacts for release
run: |
set -euxo pipefail
dist_dir=./dist/SmiServices-${{ needs.init.outputs.build_ref }}.zip
[ ! -d "$dist_dir" ] && { echo "No dist found"; exit 1; }
ls -l $dist_dir
mkdir ./release
cat $dist_dir/MD5SUM* >> ./release/MD5SUMS.txt
rm $dist_dir/MD5SUM*
cp $dist_dir/* ./release/
ls -l ./release
./bin/release/createReleaseChangelog.py ${{ needs.init.outputs.build_ref }}
- name: upload release
uses: softprops/action-gh-release@v1
with:
files: ./release/*
body_path: release_changelog.md
fail_on_unmatched_files: true
generate_release_notes: true