-
Notifications
You must be signed in to change notification settings - Fork 10
207 lines (191 loc) · 8.36 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
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
name: CI
on: [push, pull_request]
jobs:
build:
name: Build
runs-on: ubuntu-22.04
container:
image: "ubuntu:22.04"
steps:
- uses: actions/checkout@v2
- name: Install required dependencies
run: |
apt update
apt install -y sudo
sudo apt install --yes --no-install-recommends git
# workaround for https://github.com/actions/runner/issues/2033
- name: ownership workaround
run: git config --global --add safe.directory '*'
- name: Setup .NET
run: |
# We need to install `ca-certificates`, otherwise we get these errors in the CI:
# Unable to load the service index for source https://api.nuget.org/v3/index.json.
# The SSL connection could not be established, see inner exception.
# The remote certificate is invalid because of errors in the certificate chain: UntrustedRoot
apt install --yes --no-install-recommends ca-certificates
apt install --yes --no-install-recommends dotnet6
- name: Compile the conventions solution
run: dotnet build --configuration Release conventions.sln
- name: Compile F# scripts
run: dotnet fsi scripts/compileFSharpScripts.fsx
file-conventions-tests:
name: Run FileConventions-lib unit tests
needs: build
runs-on: ubuntu-22.04
container:
image: "ubuntu:22.04"
steps:
- uses: actions/checkout@v2
- name: Install required dependencies
run: |
apt update
apt install --yes sudo
- name: Setup .NET
run: |
# We need to install `ca-certificates`, otherwise we get these errors in the CI:
# Unable to load the service index for source https://api.nuget.org/v3/index.json.
# The SSL connection could not be established, see inner exception.
# The remote certificate is invalid because of errors in the certificate chain: UntrustedRoot
apt install --yes --no-install-recommends ca-certificates
apt install --yes --no-install-recommends dotnet6
- name: Run tests to validate F# scripts
run: dotnet test src/FileConventions.Test/FileConventions.Test.fsproj
commitlint-plugins-tests:
name: Run commitlint-related tests
needs: build
runs-on: ubuntu-22.04
container:
image: "ubuntu:22.04"
steps:
- uses: actions/checkout@v2
- name: Install required dependencies
run: |
apt update
apt install --yes sudo
sudo apt install --yes --no-install-recommends git ca-certificates
sudo apt install --yes --no-install-recommends npm curl
# need to update nodejs because with ubuntu's default nodejs version we would get this error:
# error @jest/[email protected]: The engine "node" is incompatible with this module. Expected version "^14.15.0 || ^16.10.0 || >=18.0.0". Got "12.22.9"
sudo npm install --global n
sudo n lts
- name: Print versions
run: |
git --version
node --version
npm --version
- name: Install yarn
run: |
npm install --global yarn
yarn add --dev jest typescript ts-jest @types/jest
- name: Install commitlint
run: |
npm install conventional-changelog-conventionalcommits
npm install commitlint@latest
- name: Print versions
run: |
git --version
node --version
npm --version
npx commitlint --version
yarn --version
- name: Run tests to validate our plugins
run: yarn jest
sanity-check:
name: Sanity check
needs:
- file-conventions-tests
- commitlint-plugins-tests
runs-on: ubuntu-22.04
container:
image: "ubuntu:22.04"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Install required dependencies
run: |
apt update && apt install --yes sudo
sudo apt install --yes --no-install-recommends git
sudo apt install --yes --no-install-recommends npm curl
# need to update nodejs because with ubuntu's default nodejs version we would get this error:
# ```
# + npx commitlint --from HEAD~1 --to HEAD --verbose
# /__w/conventions/conventions/node_modules/typescript/lib/typescript.js:139
# for (let i = startIndex ?? 0; i < array.length; i++) {
# ^
#
# SyntaxError: Unexpected token '?'
# at wrapSafe (internal/modules/cjs/loader.js:915:16)
# ...
# ```
sudo npm install --global n
sudo n lts
- uses: actions/checkout@v2
with:
submodules: recursive
# needed because of commit-lint, see https://github.com/conventional-changelog/commitlint/issues/3376
fetch-depth: 0
# workaround for https://github.com/actions/runner/issues/2033
- name: ownership workaround
run: git config --global --add safe.directory '*'
- name: Print versions
run: |
git --version
node --version
npm --version
- name: Validate current commit (last commit) with commitlint
if: github.event_name == 'push'
run: ./commitlint.sh --from HEAD~1 --to HEAD --verbose
- name: Validate PR commits with commitlint
if: github.event_name == 'pull_request'
run: |
./commitlint.sh --verbose \
--from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} \
--to ${{ github.event.pull_request.head.sha }}
- name: Setup .NET
run: |
# We need to install `ca-certificates`, otherwise we get these errors in the CI:
# Unable to load the service index for source https://api.nuget.org/v3/index.json.
# The SSL connection could not be established, see inner exception.
# The remote certificate is invalid because of errors in the certificate chain: UntrustedRoot
apt install --yes --no-install-recommends ca-certificates
apt install --yes --no-install-recommends dotnet6
- name: Check all files end with EOL
run: dotnet fsi scripts/eofConvention.fsx
- name: Check all .fsx scripts have shebang
run: dotnet fsi scripts/shebangConvention.fsx
- name: Check there are no mixed line-endings in any files
run: dotnet fsi scripts/mixedLineEndings.fsx
- name: Check there are no unpinned GitHubActions image versions
run: dotnet fsi scripts/unpinnedGitHubActionsImageVersions.fsx
- name: Check there are no unpinned dotnet package versions
run: dotnet fsi scripts/unpinnedDotnetPackageVersions.fsx
- name: Check there are no unpinned nuget package reference versions in F# scripts
run: dotnet fsi scripts/unpinnedNugetPackageReferenceVersions.fsx
- name: Check there are no unpinned versions in `dotnet tool install` commands
run: dotnet fsi scripts/unpinnedDotnetToolInstallVersions.fsx
- name: Check if gitPush1by1 was used
if: github.event_name == 'pull_request'
run: dotnet fsi scripts/detectNotUsingGitPush1by1.fsx
- name: Install prettier
run: npm install [email protected]
- name: Change file permissions
# We need this step so we can change the files using `npx prettier --write` in the next step.
# Otherwise we get permission denied error in the CI.
run: sudo chmod 777 -R .
- name: Run "prettier" to check the style of our TypeScript and YML code
run: |
sudo npx prettier --quote-props=consistent --write './**/*.ts'
sudo npx prettier --quote-props=consistent --write './**/*.yml'
# Since we changed file modes in the previous step we need the following command to
# make git ignore mode changes in files and doesn't include them in the git diff command.
git config core.fileMode false
# Since after installing commitlint dependencies package.json file changes, we need to
# run the following command to ignore package.json file
git restore package.json
git diff --exit-code
- name: fantomless
run: |
dotnet new tool-manifest
dotnet tool install fantomless-tool --version 4.7.997-prerelease
dotnet fantomless --recurse .
git diff --exit-code