-
Notifications
You must be signed in to change notification settings - Fork 2
86 lines (78 loc) · 2.97 KB
/
build.yml
File metadata and controls
86 lines (78 loc) · 2.97 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
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Build
on:
push:
paths-ignore: ['README.md']
branches: [ main ]
tags:
- 'v*.*.*'
pull_request:
branches: [ main ]
workflow_dispatch:
jobs:
build:
runs-on: [self-hosted, arm]
env:
SERVICE_UNIT_NAME: 'tarpn-core-${{ github.sha }}-${{ github.run_id }}'
steps:
- name: Clean working directory
shell: bash
run: |
echo "Cleaning up previous run"
rm -rf "$GITHUB_WORKSPACE/*"
- uses: actions/checkout@v2
- name: Install dependencies
run: |
python3.7 -m pip install --upgrade pip
python3.7 -m pip install virtualenv
python3.7 -m virtualenv venv
source venv/bin/activate
pip install -e .[develop]
python setup.py bdist_wheel
python setup.py sdist
- name: Test with pytest
run: |
source venv/bin/activate
pytest
- name: Archive prebuilt wheel
uses: actions/upload-artifact@v2
with:
name: dist
path: dist
- name: Setup BATS
uses: mig4/setup-bats@v1
- name: Setup Bats libs
uses: brokenpip3/setup-bats-libs@0.1.0
- name: Install package and systemd unit
run: |
mkdir -p ~/.config/systemd/user/
bats -t scripts/test-install.bats
echo "Patched service unit:"; cat scripts/tarpn-core.service
cp scripts/tarpn-core.service ~/.config/systemd/user/${SERVICE_UNIT_NAME}.service
echo "Installing service"
loginctl enable-linger pi
sleep 1
XDG_RUNTIME_DIR=/run/user/$UID systemctl --user daemon-reload
XDG_RUNTIME_DIR=/run/user/$UID systemctl --user enable $SERVICE_UNIT_NAME || (echo "Failed to enable service"; exit 1)
XDG_RUNTIME_DIR=/run/user/$UID systemctl --user start $SERVICE_UNIT_NAME || (echo "Failed to start service"; exit 1)
sleep 10
XDG_RUNTIME_DIR=/run/user/$UID systemctl --user status $SERVICE_UNIT_NAME > status.txt || exit 0
echo "systemctl status:"; cat status.txt
grep -i started status.txt || (echo "Service didn't start"; exit 1)
test -f ${SERVICE_UNIT_NAME}/config/node.ini || (echo "Should have bootstrapped default config file node.ini"; exit 1)
grep -i callsign status.txt || (echo "Should have failed with default config"; exit 1)
sleep 1
- name: Cleanup install
if: always()
run: |
XDG_RUNTIME_DIR=/run/user/$UID systemctl --user disable $SERVICE_UNIT_NAME || echo "Failed to disable service"
rm -f ~/.config/systemd/user/${SERVICE_UNIT_NAME}.service
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: dist/*
prerelease: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}