-
-
Notifications
You must be signed in to change notification settings - Fork 87
114 lines (101 loc) · 4.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
---
name: Merge Tests
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
build:
name: CI Build
runs-on: ubuntu-22.04
steps:
- name: Git Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup testing environment
id: deps
run: |
sudo curl -sL -o /bin/hadolint "https://github.com/hadolint/hadolint/releases/download/v2.12.0/hadolint-Linux-x86_64"
sudo chmod +x /bin/hadolint
echo "127.0.0.1 dashboard.openwisp.org api.openwisp.org" | sudo tee -a /etc/hosts
# disable metric collection during builds
sed -i 's/METRIC_COLLECTION=True/METRIC_COLLECTION=False/' .env
sudo pip3 install -r requirements-test.txt
- name: QA checks
run: ./run-qa-checks
- name: Use the auto-install script to start containers with edge images
id: auto_install_edge
if: ${{ !cancelled() && steps.deps.conclusion == 'success' }}
run: |
(sudo -E ./deploy/auto-install.sh <<EOF
edge
./.env
EOF
) || (docker compose --file /opt/openwisp/docker-openwisp/docker-compose.yml logs && exit 1)
- name: Build Images
id: build_images
if: ${{ !cancelled() && steps.auto_install_edge.conclusion == 'success' }}
run: make compose-build nfs-build
- name: Set GIT_BRANCH
id: set_git_branch
if: ${{ !cancelled() && steps.build_images.conclusion == 'success' }}
run: |
if [ "${{ github.event_name }}" == "pull_request" ]; then
GIT_BRANCH="${{ github.head_ref }}"
GIT_PATH="https://github.com/${{ github.event.pull_request.head.repo.full_name }}.git"
else
GIT_BRANCH="${{ github.ref_name }}"
fi
echo "GIT_PATH=$GIT_PATH" >> $GITHUB_ENV
echo "GIT_BRANCH=$GIT_BRANCH" >> $GITHUB_ENV
- name: Use auto-install script to upgrade containers to latest version
id: auto_install_upgrade
if: ${{ !cancelled() && steps.set_git_branch.conclusion == 'success' }}
# Do not remove the blank lines from the input.
run: |
(GIT_BRANCH="${GIT_BRANCH}" SKIP_PULL=true sudo -E ./deploy/auto-install.sh --upgrade <<EOF
latest
EOF
) || (cat /opt/openwisp/autoinstall.log && exit 1)
- name: Test
if: ${{ !cancelled() && steps.auto_install_upgrade.conclusion == 'success' }}
# The auto-install script installs docker-openwisp by default in
# /opt/openwisp/docker-openwisp. To ensure the test runs correctly
# and environment variables remain intact, it is essential to
# execute the test from this directory.
run: |
(make develop-pythontests && make stop) || (docker compose logs && exit 1)
working-directory: /opt/openwisp/docker-openwisp
env:
SELENIUM_HEADLESS: 1
# the following action is equivalent to
# echo "$DOCKER_HUB_SECRET" | docker login --username "$DOCKER_HUB_USERNAME" --password-stdin
- name: Login to Docker Hub
if: ${{ success() && github.event_name == 'push' && github.ref == 'refs/heads/master' }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_SECRET }}
# Skip image builds and tests since they were already done
- name: Publish to Docker Hub
if: ${{ success() && github.event_name == 'push' && github.ref == 'refs/heads/master' }}
run: |
make publish USER=docker.io/openwisp TAG=edge SKIP_BUILD=true SKIP_TESTS=true
env:
SELENIUM_HEADLESS: 1
- name: Login to GitLab Container Registry
if: ${{ success() && github.event_name == 'push' && github.ref == 'refs/heads/master' }}
uses: docker/login-action@v3
with:
registry: registry.gitlab.com
username: ${{ secrets.GITLAB_DOCKER_REGISTRY_USER }}
password: ${{ secrets.GITLAB_DOCKER_REGISTRY_TOKEN }}
# Skip image builds and tests since they were already done
- name: Publish to GitLab Container Registry
if: ${{ success() && github.event_name == 'push' && github.ref == 'refs/heads/master' }}
run: |
make publish TAG=edge SKIP_BUILD=true SKIP_TESTS=true