forked from bittercoder/Migrator.NET
-
-
Notifications
You must be signed in to change notification settings - Fork 12
139 lines (139 loc) · 5.36 KB
/
Copy pathdotnetpull.yml
File metadata and controls
139 lines (139 loc) · 5.36 KB
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
name: .NET Pull Request
on:
push:
branches: [master]
pull_request:
branches: [master, "codex/**"]
workflow_dispatch:
permissions:
contents: read
concurrency:
group: live-databases-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
name: Test (${{ matrix.database }})
runs-on: ubuntu-22.04
timeout-minutes: 35
strategy:
fail-fast: false
matrix:
database: [Unit, SQLite, SQLServer, PostgreSQL, Oracle, MySQL, MariaDB, Firebird, Db2, Informix, Sybase, Hana]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
- name: Start database
shell: bash
run: |
mkdir -p TestResults
bash .github/scripts/start-database.sh "${{ matrix.database }}" 2>&1 | tee TestResults/startup.log
timeout-minutes: 15
- name: Build
run: dotnet build Migrator.slnx -p:LiveDatabase=${{ matrix.database }}
- name: Configure native IBM drivers
if: matrix.database == 'Db2' || matrix.database == 'Informix'
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y libaio1 libxml2 unixodbc libncurses5
output="$GITHUB_WORKSPACE/src/Migrator.Tests/bin/Debug/net9.0"
if [ "${{ matrix.database }}" = Db2 ]; then
echo "DB2_CLI_DRIVER_INSTALL_PATH=$output/clidriver" >> "$GITHUB_ENV"
echo "LD_LIBRARY_PATH=$output/clidriver/lib" >> "$GITHUB_ENV"
else
echo "DELIMIDENT=y" >> "$GITHUB_ENV"
echo "INFORMIXDIR=$output/native" >> "$GITHUB_ENV"
echo "LD_LIBRARY_PATH=$output/native/lib:$output/native/lib/cli:$output/native/lib/esql" >> "$GITHUB_ENV"
fi
- name: Test
shell: pwsh
run: ./.github/scripts/test.ps1 -Database ${{ matrix.database }} -Coverage
- name: Verify coverage was collected
run: python3 .github/scripts/normalize-code-coverage.py TestResults
- name: Collect database logs
if: always()
run: |
mkdir -p TestResults
if docker inspect migrator-db >/dev/null 2>&1; then
docker logs migrator-db > TestResults/database.log 2>&1
docker inspect migrator-db > TestResults/container.json
fi
- uses: actions/upload-artifact@v4
if: always()
with:
name: test-results-${{ matrix.database }}
overwrite: true
path: TestResults/
if-no-files-found: error
- name: Remove test container
if: always()
run: |
if docker inspect migrator-db >/dev/null 2>&1; then
docker rm -fv migrator-db
fi
coverage:
name: Code coverage and PR comparison
needs: test
runs-on: ubuntu-22.04
timeout-minutes: 10
permissions:
contents: read
actions: read
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
pattern: test-results-*
path: TestResults
- run: python3 .github/scripts/verify-test-coverage.py TestResults
- run: python3 .github/scripts/test-code-coverage.py
- uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
- name: Merge coverage and generate HTML report
run: |
dotnet tool install dotnet-reportgenerator-globaltool --version 5.4.18 --tool-path "$RUNNER_TEMP/reportgenerator"
"$RUNNER_TEMP/reportgenerator/reportgenerator" '-reports:TestResults/*/coverage/coverage.cobertura.xml' '-targetdir:artifacts/coverage' '-reporttypes:Html;Cobertura'
- name: Find coverage for the exact PR base commit
if: github.event_name == 'pull_request'
id: baseline
uses: actions/github-script@v7
with:
script: |
const base = context.payload.pull_request.base;
// Only trust reports from successful push/manual runs in this repository.
const runs = await github.paginate(github.rest.actions.listWorkflowRuns, {
...context.repo, workflow_id: 'dotnetpull.yml', head_sha: base.sha,
status: 'success', per_page: 100
});
for (const run of runs) {
if (!['push', 'workflow_dispatch'].includes(run.event) || run.head_branch !== base.ref) continue;
const artifacts = await github.paginate(github.rest.actions.listWorkflowRunArtifacts, {
...context.repo, run_id: run.id, per_page: 100
});
if (artifacts.some(a => a.name === 'code-coverage' && !a.expired)) {
core.setOutput('run-id', String(run.id));
break;
}
}
- name: Download baseline coverage
if: steps.baseline.outputs.run-id != ''
uses: actions/download-artifact@v4
with:
name: code-coverage
path: artifacts/baseline
github-token: ${{ github.token }}
run-id: ${{ steps.baseline.outputs.run-id }}
- name: Write coverage and delta to the PR check summary
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.sha }}
run: python3 .github/scripts/summarize-code-coverage.py
- uses: actions/upload-artifact@v4
with:
name: code-coverage
path: artifacts/coverage/
if-no-files-found: error
retention-days: 90