-
Notifications
You must be signed in to change notification settings - Fork 5
185 lines (182 loc) · 7.02 KB
/
build.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
name: Build
on:
push:
workflow_dispatch:
inputs:
branch:
description: 'Branch to run the workflow on'
required: true
default: 'master'
schedule:
# Once week 04:18 on Saturday
- cron: '18 4 * * Sat'
# This allows a subsequently queued workflow run to interrupt previous runs
concurrency:
group: snap-pelion-edge-${{ github.event.pull_request.head.label || github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
build-snap:
runs-on: [ "self-hosted", "snap" ]
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
steps:
- name: Enable write on all files
run: chmod a+w -R .
- name: Check out code
uses: actions/checkout@v4
with:
# Use the branch specified by the workflow_dispatch input or the pull_request event
ref: ${{ github.event.inputs.branch || github.event.pull_request.head.ref }}
- name: Copy mbed_cloud_dev_credentials.c
env:
MBED_CLOUD_DEV_CREDENTIALS: ${{ secrets.MBED_CLOUD_DEV_CREDENTIALS_SNAP_CI }}
run: |
echo "$MBED_CLOUD_DEV_CREDENTIALS" > mbed_cloud_dev_credentials.c
- name: Copy update_default_resources.c
env:
UPDATE_DEFAULT_RESOURCES: ${{ secrets.UPDATE_DEFAULT_RESOURCES_SNAP_CI }}
run: |
echo "$UPDATE_DEFAULT_RESOURCES" > update_default_resources.c
- name: Build Docker image
run: |
docker build --no-cache -f Dockerfile --label snapcore/snapcraft --tag ${USER}/snapcraft:latest .
- name: Build snap
run: |
# If previous run failed, set everything to write mode.
chmod a+w -R .
docker run --rm -v "$PWD":/build -w /build ${USER}/snapcraft:latest bash -c "sudo apt-get update && snapcraft --debug"
# The build left files with no write rights, which ruins next test run
chmod a+w -R .
- name: Archive the snap-binary
uses: actions/upload-artifact@v4
with:
name: pelion-edge-amd64.snap
path: ./pelion-edge*.snap
if-no-files-found: error
- name: Archive connect.sh
uses: actions/upload-artifact@v4
with:
name: connect.sh
path: ./connect.sh
if-no-files-found: error
- name: Post status to Slack testing_builds
if: always()
uses: act10ns/slack@v2
with:
status: ${{ job.status }}
channel: '#testing_builds'
test:
runs-on: ubuntu-22.04
needs: build-snap
timeout-minutes: 40
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
steps:
- name: Check out code
uses: actions/checkout@v4
with:
# Use the branch specified by the workflow_dispatch input or the pull_request event
ref: ${{ github.event.inputs.branch || github.event.pull_request.head.ref }}
- name: Check out e2e-edge-test-suite repo
uses: actions/checkout@v4
with:
repository: PelionIoT/e2e-edge-test-suite
path: e2e-edge-test-suite
token: ${{ secrets.ACCESS_TOKEN }}
- name: Check out scripts-internal repo
uses: actions/checkout@v4
with:
repository: PelionIoT/scripts-internal
path: scripts-internal
token: ${{ secrets.ACCESS_TOKEN }}
- name: Set up Python v3.8
uses: actions/setup-python@v5
with:
python-version: v3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r e2e-edge-test-suite/requirements.txt
sudo apt install virtualenv
curl -LO https://dl.k8s.io/release/v1.25.0/bin/linux/amd64/kubectl
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
kubectl version --client
- name: Get pelion-edge.snap from storage
uses: actions/download-artifact@v4
with:
name: pelion-edge-amd64.snap
path: e2e-edge-test-suite
- name: Get connect.sh from storage
uses: actions/download-artifact@v4
with:
name: connect.sh
path: e2e-edge-test-suite
- name: Install snap as sudo and test
run: |
snapfile=$(ls e2e-edge-test-suite/*.snap)
sudo scripts-internal/snap/snap-install.sh -s $snapfile
sleep 5
if sudo snap restart pelion-edge; then
echo "sudo snap restart succeeded."
else
echo "sudo snap restart pelion-edge failed. Test results might be invalid."
fi
sleep 5
snap services
snap list
pelion-edge.help
pelion-edge.edge-info
pelion-edge.version
pelion-edge.edge-testnet
pelion-edge.curl --version
- name: Check snap-pelion-edge versions
run: |
sudo snap install yq
snapcraftyamlver=$(yq -r ".version" <snap/snapcraft.yaml |sed -r "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2};?)?)?[mGK]//g")
version=$(pelion-edge.version |grep snap-pelion-edge | awk -F' ' '{ print $NF }')
if [[ "$snapcraftyamlver" != "$version" ]]; then
echo "FAIL - Snapcraft.yaml and pelion-edge.version versions differ: $snapcraftyamlver vs. $version"
exit 1
fi
snapver=$(snap list |grep "pelion-edge" | awk -F' ' '{ print $2 }')
if [[ "$snapcraftyamlver" != "$snapver" ]]; then
echo "FAIL - Snapcraft.yaml and snap list versions differ: '$snapcraftyamlver' vs. '$snapver'"
exit 1
fi
infover=$(pelion-edge.edge-info |grep "Pelion Edge Version:" | awk -F' ' '{ print $NF }' |sed -r "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2};?)?)?[mGK]//g" )
if [[ "$snapcraftyamlver" != "$infover" ]]; then
echo "FAIL - Snapcraft.yaml and pelion-edge.edge-info versions differ: '$snapcraftyamlver' vs. '$infover'"
exit 1
fi
# Disabled for now - reboot is required to get installation working correctly,
# we cannot however reboot a GitHub runner mid-job.
# - name: Run snap-test
# if: ${{ failure() }} || ${{ success() }}
# run: |
# cd e2e-edge-test-suite
# ../scripts-internal/snap/snap-test.sh -a ${{ secrets.IZUMA_ACCESS_KEY }}
- name: Remove snap
if: always()
run: |
sudo scripts-internal/snap/snap-remove.sh -a ${{ secrets.IZUMA_ACCESS_KEY }} -s pelion-edge
# - name: Archive the pytest.log
# uses: actions/upload-artifact@v4
# with:
# name: pytest.log
# path: e2e-edge-test-suite/pytest.log
# if-no-files-found: error
# - name: Publish Test Results
# uses: EnricoMi/publish-unit-test-result-action@v2
# if: always()
# with:
# files: |
# results.xml
- name: Clean up .gitconfig
if: always()
run: rm -f ~/.gitconfig
- name: Post status to Slack testing_builds
if: always()
uses: act10ns/slack@v2
with:
status: ${{ job.status }}
channel: '#testing_builds'