-
Notifications
You must be signed in to change notification settings - Fork 40
161 lines (132 loc) · 4.28 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# This is alight weight build and test, suitable for rapid checks of commits on feature branches etc.
name: CI
on:
push: # Trigger on pushes to feature branches for safety before a PR
branches-ignore:
- main # don't run on main (build.yml handles that)
paths-ignore:
- docs/
pull_request:
branches:
- main
paths-ignore:
- docs/
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
build-code:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET 8
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: |
dotnet restore -r linux-x64 grate.sln
- name: Build
run: dotnet build -f net8.0 --no-restore --no-self-contained -r linux-x64 src/grate/grate.csproj -c release
analyze:
name: Analyze Code Security
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup .NET 8
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
7.0.x
8.0.x
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
- name: Autobuild
uses: github/codeql-action/autobuild@v3
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
test:
name: Run tests
runs-on: ubuntu-latest
#needs: build-code
strategy:
fail-fast: false
matrix:
category: [ "Basic_tests", "SqlServer", "PostgreSQL", "MariaDB", "Sqlite", "Oracle" ]
#category: [ "Basic_tests", "Sqlite" ]
steps:
- uses: actions/checkout@v4
- name: Setup .NET 8
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Test
run: |
dotnet test \
unittests/${{ matrix.category }} \
--logger:"xunit;LogFilePath=/tmp/test-results/${{ matrix.category }}.xml" -- \
-MaxCpuCount 2
env:
LogLevel: Warning
TZ: UTC
- name: Upload Unit Test Results
if: always()
uses: actions/upload-artifact@v4
with:
name: "${{ matrix.category }} XML test results"
path: |
/tmp/test-results/${{ matrix.category }}.xml
retention-days: 1
report:
runs-on: ubuntu-latest
name: Create test report
needs: test
if: always()
steps:
- name: Download XML test reports
uses: actions/download-artifact@v4
with:
path: test-results
- name: Install smink
run: |
BASEURL="https://github.com/erikbra/smink/releases/download/"
VERSION="0.3.0"
INSTALL_DIR="/tmp/smink"
SMINK="${INSTALL_DIR}/smink"
FILENAME="smink-linux-x64-${VERSION}.zip"
FULL_URL="${BASEURL}${VERSION}/${FILENAME}"
DOWNLOAD_DIR="/tmp/smink-download"
DOWNLOAD_FILE="${DOWNLOAD_DIR}/${FILENAME}"
test -f "${SMINK}" && \
echo "smink already installed - not installing" || \
echo "Installing smink v ${VERSION}" && \
(test -d "${DOWNLOAD_DIR}" || mkdir -p "${DOWNLOAD_DIR}") && \
(test -d "${INSTALL_DIR}" || mkdir -p "${INSTALL_DIR}") && \
(test -f "${DOWNLOAD_FILE}" || curl -o "${DOWNLOAD_FILE}" -sL "${FULL_URL}") && \
unzip -o "${DOWNLOAD_FILE}" -d "${INSTALL_DIR}"
chmod u+x "${SMINK}"
- name: Create HTML test report
run: |
XML_DIR='/tmp/xml'
REPORT_DIR='/tmp/test-results'
test -d $XML_DIR || mkdir $XML_DIR
find "test-results" -name '*.xml' -exec cp "{}" $XML_DIR \;
echo "Found the following test results files:"
ls -1 $XML_DIR
test -d $REPORT_DIR || mkdir $REPORT_DIR
echo "Running smink"
/tmp/smink/smink "${XML_DIR}/*.xml" "${REPORT_DIR}/test-report.html" --title "grate unit tests"
- name: Upload HTML test report
uses: actions/upload-artifact@v4
with:
name: HTML test report
path: |
/tmp/test-results/test-report.html
retention-days: 1