-
-
Notifications
You must be signed in to change notification settings - Fork 4
143 lines (118 loc) · 4.11 KB
/
test_docker_image.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
name: Tests
# This file contains 3 jobs that run in parallel
on:
workflow_dispatch: # Allow manually running
workflow_call: # Allow another workflow to call this one
pull_request:
types:
- opened
- reopened
- edited
- synchronize
branches: # Target
- 'main'
- 'dev'
# push:
# branches:
# - 'group-updates'
# tags:
# - 'v*'
jobs:
python_unit_test_and_coverage:
name: Python tests and coverage
# if: contains(github.event.head_commit.message, '[ci]')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
run: |
echo "Installing python requirements"
pip install -r requirements-dev.txt
- name: Run Black format
run: python3 -m black --verbose --check --line-length 120 app
- name: Prepare enviornment variables
run: |
echo "NAUTICAL_DB_PATH=${GITHUB_WORKSPACE}/dev/config" >> "$GITHUB_ENV"
echo "SOURCE_LOCATION=${GITHUB_WORKSPACE}/dev/source" >> "$GITHUB_ENV"
echo "DEST_LOCATION=${GITHUB_WORKSPACE}/dev/destination" >> "$GITHUB_ENV"
echo "LOG_LEVEL=DEBUG" >> "$GITHUB_ENV"
- name: Create necessary folders
run: |
mkdir -p $NAUTICAL_DB_PATH
mkdir -p $SOURCE_LOCATION
mkdir -p $DEST_LOCATION
- name: Run tests and collect coverage
run: |
echo "NAUTICAL_DB_PATH: ${NAUTICAL_DB_PATH}"
python3 -m pytest --cov app --cov-report html --cov-report term --cov-report xml
- name: Upload reports to Codecov
uses: codecov/codecov-action@v5
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} # Required for v4
with:
fail_ci_if_error: true
files: coverage.xml
- name: Archive code coverage results
uses: actions/upload-artifact@v4
with:
name: python-code-coverage
path: htmlcov/
retention-days: 5
test_docker_architecture:
name: Validate Docker Architecture
# if: contains(github.event.head_commit.message, '[ci]')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Validate Dockerfile supports multi-arch
run: |
echo "Checking if the base docker image supports amd64 and arm64..."
bash ./tests/_validate_dockerfile.sh
bash_unit_test_and_coverage:
name: Integration tests
# if: contains(github.event.head_commit.message, '[ci]')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and export Docker image
uses: docker/build-push-action@v6.10.0
with:
context: .
load: true # Do not push this image
tags: minituff/nautical-test
build-args: TEST_MODE=0
- name: Run built image against Docker image
run: |
cd tests
docker compose run nautical-backup-test1
docker compose run nautical-backup-test2
- name: Run integration tests against Docker image
timeout-minutes: 3
run: |
cd tests
rm -rf source config
mkdir -p source/watchtower-test
echo "This is a test file" >> source/watchtower-test/test-file.txt
docker compose -f watchtower.yml up -d
docker compose run nautical-backup-test3
docker compose -f watchtower.yml down
bash ./_validate_rsync.sh
# - name: Upload reports to Codecov
# uses: codecov/codecov-action@v4
# env:
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} # Required for v4
# with:
# fail_ci_if_error: true
# files: tests/coverage/coverage.xml # The json file will not work here
# - name: Archive code coverage results
# uses: actions/upload-artifact@v4
# with:
# name: bash-code-coverage
# path: tests/coverage/
# retention-days: 5