forked from logikal-io/github-workflows
-
Notifications
You must be signed in to change notification settings - Fork 0
112 lines (102 loc) · 3.44 KB
/
run-python-tests.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
name: Run Python tests
on:
workflow_call:
inputs:
python-version:
description: The Python version to use
type: number
required: false
default: 3.8
requirements:
description: The path to the requirements file
type: string
required: false
default: requirements/dev.txt
fetch-depth:
description: Number of commits to fetch
type: string
required: false
default: 1
pytest-options:
description: The pytest command-line arguments to use
type: string
required: false
playbook-roles:
description: The Logikal playbook roles to run (comma-separated list)
type: string
required: false
playbook-vars:
description: The Logikal playbook variables to set (string-encoded JSON)
type: string
required: false
default: '{}'
upload-artifacts:
description: Whether the upload artifacts when tests fail
type: boolean
required: false
default: true
secrets:
GCP_TESTING_WORKLOAD_IDENTITY_PROVIDER:
description: Full identifier of the GitHub workload identity pool provider in Google Cloud
required: false
GCP_TESTING_SERVICE_ACCOUNT:
description: Email of the Google Cloud service account used for running tests
required: false
AWS_TESTING_ROLE:
description: The ARN of the AWS role used for running tests
required: false
AWS_TESTING_REGION:
description: The AWS region to use for authorization
required: false
concurrency:
group: ${{ github.workflow }}-python-${{ github.ref || github.run_id }}
cancel-in-progress: true
jobs:
run-tests:
name: Run tests
runs-on: ubuntu-20.04
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: ${{ inputs.fetch-depth }}
- name: Authenticate to Google Cloud Platform
uses: google-github-actions/auth@v2
env:
RUN_STEP: ${{ secrets.GCP_TESTING_SERVICE_ACCOUNT != '' }}
if: env.RUN_STEP == 'true'
with:
workload_identity_provider: ${{ secrets.GCP_TESTING_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GCP_TESTING_SERVICE_ACCOUNT }}
- name: Authenticate to Amazon Web Services
uses: aws-actions/configure-aws-credentials@v4
env:
RUN_STEP: ${{ secrets.AWS_TESTING_ROLE != '' }}
if: env.RUN_STEP == 'true'
with:
aws-region: ${{ secrets.AWS_TESTING_REGION }}
role-to-assume: ${{ secrets.AWS_TESTING_ROLE }}
- uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}
- name: Run playbooks
uses: logikal-io/run-logikal-playbook@v2
if: inputs.playbook-roles != ''
with:
roles: ${{ inputs.playbook-roles }}
vars: ${{ inputs.playbook-vars }}
- uses: logikal-io/make-orb@v1
with:
requirements: ${{ inputs.requirements }}
- name: Run pytest
run: orb --command 'pytest ${{ inputs.pytest-options }}'
- name: Upload pytest artifacts
uses: actions/upload-artifact@v4
if: failure() && inputs.upload-artifacts
with:
name: pytest-artifacts
path: /tmp/pytest-of-runner/
if-no-files-found: ignore
retention-days: 7