-
-
Notifications
You must be signed in to change notification settings - Fork 59
110 lines (93 loc) · 3.09 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
name: OpenWISP Config CI Build
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
tests:
name: QA-Checks and Tests
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Install Dependencies
id: deps
run: |
sudo ./install-dev.sh
pip install openwisp-utils[qa]>=0.7
- name: QA-Checks
run: ./run-qa-checks
env:
CI: 1
- name: Run sh-checker
if: ${{ !cancelled() && steps.deps.conclusion == 'success' }}
uses: luizm/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
sh_checker_comment: true
- name: Tests
if: ${{ !cancelled() && steps.deps.conclusion == 'success' }}
run: ./runtests
build:
name: Build and Upload Packages
needs: tests
runs-on: ubuntu-24.04
env:
BUILD_DIR: "/home/runner/work/build"
DOWNLOADS_DIR: "/home/runner/work/downloads"
CORES: 2
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Cache OpenWrt dependencies
id: cache
uses: actions/cache@v4
env:
cache-name: cache-openwisp-config-dependencies
with:
path: "/home/runner/work/build"
key: ${{ runner.os }}-build-${{ env.cache-name }}
- name: Set Environment
run: |
echo "START_TIME=$(date +"%Y-%m-%d")" >> $GITHUB_ENV
echo "COMMIT_SHA=$(git log --pretty=format:'%h' -n 1)" >> $GITHUB_ENV
- name: Run Build
run: ./runbuild
env:
CI: 1
CI_CACHE: ${{ steps.cache.outputs.cache-hit }}
- name: Upload packages as artifacts
uses: actions/upload-artifact@v4
with:
name: Packages
path: "${{ env.DOWNLOADS_DIR }}/${{ env.START_TIME }}"
- name: Google Cloud Auth
if: ${{ github.event_name=='push' }}
uses: 'google-github-actions/auth@v2'
with:
project_id: ${{ secrets.GCS_PROJECT_ID }}
credentials_json: ${{ secrets.GCS_DOWNLOADS_SERVICE_ACCOUNT_JSON }}
- name: Google Cloud Setup
if: ${{ github.event_name=='push' }}
uses: google-github-actions/setup-gcloud@v2
with:
project_id: ${{ secrets.GCS_PROJECT_ID }}
- name: Upload compiled packages to downloads.openwisp.io
if: ${{ github.event_name=='push' }}
run: |
gsutil -m rsync -r ${{ env.SRC_URL }} ${{ env.DST_URL }}
gsutil -m rsync -r -d ${{ env.SRC_URL }} ${{ env.LATEST_URL }}
env:
SRC_URL: ${{ env.DOWNLOADS_DIR }}/${{ env.START_TIME }}/openwisp
DST_URL: gs://${{ secrets.GCS_DOWNLOADS_BUCKET_NAME }}/openwisp-config/${{ env.START_TIME }}-${{ env.COMMIT_SHA }}
LATEST_URL: gs://${{ secrets.GCS_DOWNLOADS_BUCKET_NAME }}/openwisp-config/latest