-
Notifications
You must be signed in to change notification settings - Fork 1
167 lines (140 loc) · 4.84 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
name: CI
on:
push:
pull_request:
workflow_dispatch:
# to execute once a day (more info see https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule )
schedule:
- cron: "0 0 * * *"
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{secrets.SNAPCRAFT_LOGIN}}
jobs:
build:
runs-on: ubuntu-22.04
container:
image: "ubuntu:22.04"
steps:
- uses: actions/checkout@v1
- name: Install required dependencies
run: |
apt update
apt install --yes sudo
sudo apt install --yes --no-install-recommends git
# workaround for https://github.com/actions/runner/issues/2033
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 dotnet7
- name: Build
run: dotnet build
build_snap:
needs: build
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v1
- name: Install snap tools
run: |
sudo apt update
sudo apt install -y snapd
snap version
sudo snap install --classic snapcraft
# workaround for GithubActionsCI+snapcraft, see https://forum.snapcraft.io/t/permissions-problem-using-snapcraft-in-azure-pipelines/13258/14
sudo chown root:root /
snapcraft --version
# use multipass provider as lxd doesn't work for some reason
sudo snap install multipass
sudo snap set snapcraft provider=multipass
- name: Build
run: dotnet build --configuration Release
- name: Generate snap package
run: sudo snapcraft --destructive-mode --verbosity=verbose || sudo bash -c 'cat /root/.local/state/snapcraft/log/*.log'
- uses: actions/upload-artifact@v3
name: Upload snap package as artifact
with:
name: snap
path: ./*.snap
integration_tests:
strategy:
matrix:
# macos-13 is x64 and macos-14 is arm64
os: [ubuntu-22.04, macos-13, macos-14, windows-latest]
needs: build
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v1
- name: Run Tests
run: dotnet test
run_snap:
needs: build_snap
runs-on: ubuntu-22.04
steps:
- uses: actions/download-artifact@v3
name: Download artifact
with:
name: snap
- name: Install snap
run: |
zip -r snap.zip .
# dangerous because it's a local snap (not one from the SnapStore)
sudo snap install --devmode --dangerous *.snap
- name: Test snap
run: dotnet-fsharp-helloworld
conventions:
needs:
- integration_tests
- run_snap
runs-on: ubuntu-22.04
container:
image: "ubuntu:22.04"
steps:
- uses: actions/checkout@v1
- name: Install required dependencies
run: |
apt update
apt install --yes sudo
sudo apt install --yes --no-install-recommends git
# workaround for https://github.com/actions/runner/issues/2033
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: fantomas
run: |
dotnet new tool-manifest
dotnet tool install fantomas --version 6.2.3
dotnet fantomas .
git diff --exit-code
publish_snap:
needs:
- run_snap
- integration_tests
- conventions
runs-on: ubuntu-22.04
steps:
- uses: actions/download-artifact@v3
name: Download artifact
with:
name: snap
- name: Unzip
run: |
zip -r snap.zip .
- name: Install snapcraft
run: |
sudo snap install --classic snapcraft
snapcraft --version
- name: Upload to SnapStore
#FIXME: add github.event_name == 'push' condition to the 'if:' condition below?
if: startsWith(github.ref, 'refs/tags/')
run: |
# no need to 'snapcraft login' first, see https://forum.snapcraft.io/t/snapcraft-authentication-options/30473/21
snapcraft upload *.snap --release=beta