-
Notifications
You must be signed in to change notification settings - Fork 6
161 lines (131 loc) · 5.08 KB
/
actions.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
on:
push:
paths-ignore:
- "**/*.md"
pull_request:
env:
DOTNET_VERSION: 6.0.x
NODE_VERSION: 20
NPM_REGISTRY: https://registry.npmjs.org
jobs:
test:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Setup node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: ${{ env.NPM_REGISTRY }}
- name: Install dependencies
run: dotnet restore ./DbViewer.sln --verbosity minimal && dotnet tool restore
- name: Install yarn
run: corepack enable && corepack prepare [email protected] --activate
- name: Install node dependencies
run: corepack yarn --cwd db-viewer-ui --immutable
- name: Build dotnet
run: dotnet build --configuration Release ./DbViewer.sln
- name: Pack dotnet
run: dotnet pack --no-build --configuration Release ./DbViewer.sln
- name: Install Playwright
run: pwsh ./DbViewer.Tests/bin/Release/net6.0/playwright.ps1 install chromium --with-deps
- name: Build front
run: yarn --cwd db-viewer-ui build
- name: Check C# code style
run: dotnet jb cleanupcode DbViewer.sln --profile=CatalogueCleanup --exclude=./DbViewer.TestApi/Migrations/*.cs --verbosity=WARN --no-build && git diff --exit-code -- ':!./db-viewer-ui/.yarn'
- name: Check front code
run: yarn --cwd db-viewer-ui lint
- name: Build docker-compose environment
run: docker compose up -d --wait
- name: Run db-viewer api
run: docker build -t db-viewer-api ./DbViewer.TestApi && docker run -dp 5000:5000 --name db-viewer-api --network=db-viewer_default-network -e CASSANDRA_ADDRESS=cassandra -e POSTGRES_ADDRESS=postgres db-viewer-api
- name: Run EntityFramework migrations
run: dotnet ef database update --project ./DbViewer.TestApi/DbViewer.TestApi.csproj --no-build --configuration Release
- name: Run tests
run: dotnet test --no-build --configuration Release ./DbViewer.Tests/DbViewer.Tests.csproj
- name: Stop docker containers
if: always()
run: docker rm -f db-viewer-api && docker-compose down
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: packages
path: |
**/*.nupkg
**/*.tgz
if-no-files-found: error
- name: Upload Playwright traces
if: failure()
uses: actions/upload-artifact@v3
with:
name: traces
path: DbViewer.Tests/bin/Release/net6.0/out/*.zip
publish:
runs-on: ubuntu-20.04
needs: test
if: startsWith(github.event.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: packages
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Setup node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: ${{ env.NPM_REGISTRY }}
- name: Install yarn
run: corepack enable && corepack prepare [email protected] --activate
- name: Install node dependencies
run: corepack yarn --cwd db-viewer-ui --immutable
- name: Check version
run: |
tagName="${{github.ref_name}}"
echo "Will publish nuget package for $tagName tag"
# tag name starts with 'vX.Y-release' (e.g. use 'v4.2-release.1' tag for the first patch for release v4.2)
if [[ $tagName =~ v([0-9]+\.[0-9]+)-release ]] ; then
releaseVersion=${BASH_REMATCH[1]}
echo "SHOULD_CREATE_RELEASE=true" >> $GITHUB_ENV
else
releaseVersion="${tagName:1}"
fi
echo "Will create release $releaseVersion for $tagName tag"
if ! grep -Fq "\"version\": \"$releaseVersion\"" ./version.json ; then
echo "Version in tag ($releaseVersion) does not match version in version.json"
exit 1
fi
- name: Publish NuGet
run: dotnet nuget push "**/*.nupkg" --source https://api.nuget.org/v3/index.json --no-symbols --api-key ${{ env.NUGET_API_KEY }}
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
- name: Publish NPM
run: |
for file in ./db-viewer-ui/dist/*.tgz; do
echo "Will publish $file"
npm publish $file --ignore-scripts
done
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create release
uses: softprops/action-gh-release@v1
if: ${{ env.SHOULD_CREATE_RELEASE == 'true' }}
with:
fail_on_unmatched_files: true
draft: false
prerelease: false
files: |
**/*.nupkg
**/*.tgz