python #215
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |