-
Notifications
You must be signed in to change notification settings - Fork 3
138 lines (132 loc) · 3.92 KB
/
python.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
name: python
on:
push:
paths:
- "samples/python/**"
- ".github/workflows/python.yml"
- "restarter/**"
schedule:
- cron: '0 7 * * *'
env:
REGISTRY: ghcr.io
IMAGE_NAME: miracl/oidc-samples/samples/python
DOCKER_BUILD_CONTEXT: samples/python
SAMPLE_IMAGE: ghcr.io/miracl/oidc-samples/samples/python:${{ github.sha }}
PROXY_IMAGE: ghcr.io/miracl/oidc-samples/proxy:latest
TESTS_IMAGE: ghcr.io/miracl/oidc-samples/integration-tests:latest
CLIENT_ID: ${{ vars.CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
PROJECT_ID: ${{ vars.PROJECT_ID }}
jobs:
pylint-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Python
run: |
cd samples/python
python3 -m venv .venv
source .venv/bin/activate
pip3 install -r requirements.txt
pylint $(git ls-files '*.py') --fail-under=10.0 --recursive=y --enable=W
deactivate
build-docker:
needs: pylint-check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: docker/setup-buildx-action@v1
- uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: |
latest=${{ github.ref == 'refs/heads/master' }}
tags: |
type=raw,value=${{ github.sha }}
- uses: docker/build-push-action@v2
with:
context: ${{ env.DOCKER_BUILD_CONTEXT }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
run-integration-tests:
needs: build-docker
runs-on: ubuntu-latest
steps:
- name: Pull images
run: |
docker pull --quiet $SAMPLE_IMAGE
docker pull --quiet $TESTS_IMAGE
- name: Start the sample
run: docker run
--detach
--network host
--publish 8000
--name sample
--env CLIENT_ID
--env CLIENT_SECRET
$SAMPLE_IMAGE
- name: Sleep for a seconds
run: sleep 3s
shell: bash
- name: Run integration tests
run: docker run
--network host
$TESTS_IMAGE
--client-id $CLIENT_ID
--client-secret $CLIENT_SECRET
--project-id $PROJECT_ID
run-integration-tests-with-proxy:
needs: build-docker
runs-on: ubuntu-latest
steps:
- name: Pull images
run: |
docker pull --quiet $PROXY_IMAGE
docker pull --quiet $SAMPLE_IMAGE
docker pull --quiet $TESTS_IMAGE
- name: Start the proxy
run: docker run
--detach
--network host
--publish 8080
$PROXY_IMAGE
- name: Checkout repository content
uses: actions/checkout@v2
- name: Run the restarter
run: go run ./restarter/main.go &
- name: Start the sample
run: docker run
--detach
--network host
--publish 8080
--name sample
--env CLIENT_ID
--env CLIENT_SECRET
--env REQUESTS_CA_BUNDLE=/usr/local/share/ca-certificates/proxy.crt
--env PROXY_HOST=127.0.0.1
--env PROXY_PORT=8080
$SAMPLE_IMAGE
- name: Sleep for a seconds
run: sleep 4s
shell: bash
- name: Run integration tests
run: docker run
--network host
$TESTS_IMAGE
--client-id $CLIENT_ID
--client-secret $CLIENT_SECRET
--project-id $PROJECT_ID
--sample-name sample
--proxy-host 127.0.0.1
--proxy-port 8080
--skip-modify-tests false