-
Notifications
You must be signed in to change notification settings - Fork 33
183 lines (150 loc) · 6.1 KB
/
ci.yaml
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
---
name: Integration tests
on:
pull_request:
branches:
- '**'
push:
branches:
- '**'
workflow_dispatch:
jobs:
integration:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
TEST: docker
# - os: ubuntu-latest
# TEST: podman
# - os: macos-12
# TEST: docker
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
path: "oci_env"
- uses: actions/setup-python@v4
with:
python-version: "3.8"
- name: Set environment variables
run: |
echo "TEST=${{ matrix.TEST }}" >> $GITHUB_ENV
echo "COMPOSE_INTERACTIVE_NO_CLI=1" >> $GITHUB_ENV
#echo "OCI_ENV_PATH=${GITHUB_WORKSPACE}/oci_env/" >> $GITHUB_ENV
- name: clone pulpcore, pulp-openapi-generator
run: |
git clone --depth 1 https://github.com/pulp/pulpcore.git
git clone --depth 1 https://github.com/pulp/pulp-openapi-generator.git
- name: Install podman compose
if: matrix.TEST == 'podman' && matrix.os == 'ubuntu-latest'
run: |
sudo apt update
sudo apt install -y httpie podman
sudo pip install podman-compose
podman --version
- name: (Mac) Install docker compose
if: matrix.TEST == 'docker' && matrix.os == 'macos-12'
uses: docker-practice/actions-setup-docker@1.0.11
- name: setup .compose.env files
run: |
cp oci_env/.github/assets/${TEST}_compose.env oci_env/compose.env
cp oci_env/.github/assets/${TEST}_compose.env ${PWD}/custom.env
echo "API_PORT=7210" >> ${PWD}/custom.env
echo "DOCS_PORT=12346" >> ${PWD}/custom.env
echo "COMPOSE_PROJECT_NAME=my_2nd_project" >> ${PWD}/custom.env
echo "SECOND_SERVICE_PORT=7002" >> ${PWD}/custom.env
- name: setup test profiles
run: |
cp -r oci_env/.github/assets/profiles/* oci_env/profiles/
- name: install oci-env cli
run: |
pip install -e oci_env/client/
- name: Build and run the environment
run: |
oci-env compose build
oci-env compose up -d
oci-env -e custom.env compose up -d
- name: Wait for the stack to spin up
run: |
oci-env poll --wait 15 --attempts 30
oci-env -e custom.env poll --wait 5 --attempts 5
- name: Create some dummy data with the pulp CLI (retry up to 5 times because it's sometimes not actually ready)
run: for i in $(seq 1 5); do oci-env pulp file repository create --name test1 && s=0 && break || s=$? && sleep 5; done; (exit $s)
- name: Snapshot the DB
run: oci-env db snapshot
- name: Create some dummy data with the pulp CLI
run: oci-env -v pulp file repository create --name test2
- name: Test DB restore. Test that test1 exists and test2 doesn't
run: |
oci-env db restore
oci-env pulp file repository show --name test1
if oci-env pulp file repository show --name test2; then false; fi
- name: Test DB Reset. Test that test1 and test2 are gone
run: |
oci-env db reset
if oci-env pulp file repository show --name test1; then false; fi
if oci-env pulp file repository show --name test2; then false; fi
- name: Test that the correct plugins are installed and that the API_ROOT was successfully changed.
run: |
curl localhost:5001/my/custom/api/api/v3/status/ | jq -r ".versions" | grep pulpcore
curl localhost:5001/my/custom/api/api/v3/status/ | jq -r ".versions" | grep pulp-file
- name: Test that the second instance of oci-env is running correctly.
run: |
curl localhost:7210/my/custom/api/api/v3/status/ | jq -r ".versions" | grep pulpcore
curl localhost:7210/my/custom/api/api/v3/status/ | jq -r ".versions" | grep pulp-file
- name: Test functional tests
run: |
oci-env -v generate-client -i
oci-env -v generate-client -i pulp_file
oci-env -v test -i functional -k test_labels
- name: Test lint
run: oci-env -v test -i lint
- name: Test unit
run: oci-env test -i unit
- name: Test profile init scripts
run: |
oci-env exec cat /tmp/test_file1
oci-env exec cat /tmp/test_file2
- name: Test profile env vars
run: oci-env exec printenv | grep hello2
- name: Test default variables
run: |
oci-env exec printenv | grep hi_default
oci-env exec printenv | grep howdy_default
- name: Test profile custom compose definitions
run: |
curl localhost:8002 | grep test
curl localhost:7002 | grep test
- name: Print settings
run: oci-env exec dynaconf list
- name: Pass service name to exec
run: oci-env exec -s pulp ls
- name: Pass service name + number to exec
run: |
if [[ -f "/Applications/Docker.app/Contents/Resources/bin/docker" ]]; then
oci-env exec -s pulp-1 ls
else
oci-env exec -s pulp_1 ls
fi
- name: Test profile generation
run: |
oci-env profile init _test_profile
# Test that files were created correctly
ls oci_env/profiles/_test_profile/ | grep README.md
ls oci_env/profiles/_test_profile/ | grep init.sh
ls oci_env/profiles/_test_profile/ | grep pulp_config.env
ls oci_env/profiles/_test_profile/ | grep compose.yaml
ls oci_env/profiles/_test_profile/ | grep profile_requirements.txt
ls oci_env/profiles/_test_profile/ | grep profile_default_config.env
- name: Test profile ls
run: oci-env profile ls | grep _test_profile
- name: Test profile docs
run: oci-env profile docs _test_profile | grep Usage
- name: Print server logs (1st instance)
if: always()
run: oci-env compose logs
- name: Print server logs (2nd instance)
if: always()
run: oci-env -e custom.env compose logs