generated from cisagov/ScubaGear
-
Notifications
You must be signed in to change notification settings - Fork 25
129 lines (118 loc) · 4.61 KB
/
run_smoke_test.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
name: Run Smoke Test
on:
pull_request:
types: [opened, reopened]
branches:
- "main"
pull_request_review:
types: [submitted]
push:
# These paths are primarily for workflow testing purposes
paths:
- ".github/workflows/run_smoke_test.yml"
- ".github/actions/setup-dependencies-windows/action.yml"
- ".github/actions/setup-dependencies-macos/action.yml"
branches:
- "main"
- "*smoketest*"
workflow_call:
workflow_dispatch:
inputs:
operating-system:
description: "Choose operating system(s), format must be an array of strings:"
required: true
type: string
default: "['windows-latest', 'macos-latest']"
python-version:
description: "Choose python version(s), format must be an array of strings:"
required: true
type: string
default: "['3.10']"
opa-version:
description: "Choose OPA version"
required: true
type: string
default: "v0.60.0"
jobs:
configuration:
runs-on: ubuntu-latest
outputs:
operating-system: ${{ steps.variables.outputs.operating-system }}
python-version: ${{ steps.variables.outputs.python-version }}
opa-version: ${{ steps.variables.outputs.opa-version }}
steps:
- name: Configure variable outputs
id: variables
run: |
# For manual runs
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
operatingsystem_val="${{ inputs.operating-system }}"
pythonversion_val="${{ inputs.python-version }}"
opaversion_val="${{ inputs.opa-version }}"
# Default values for other events
else
operatingsystem_val="['macos-latest']"
pythonversion_val="['3.10']"
opaversion_val="0.60.0"
fi
echo "operating-system=$operatingsystem_val" >> "$GITHUB_OUTPUT"
echo "python-version=$pythonversion_val" >> "$GITHUB_OUTPUT"
echo "opa-version=$opaversion_val" >> "$GITHUB_OUTPUT"
smoke-test:
needs: configuration
strategy:
fail-fast: false
matrix:
operating-system: ${{ fromJSON(needs.configuration.outputs.operating-system) }}
# See https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json,
# ctrl + f and search "python-3.<minor>.<patch>-<darwin-arm64/win32/linux>" for supported versions
python-version: ${{ fromJSON(needs.configuration.outputs.python-version) }}
runs-on: ${{ matrix.operating-system }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Setup Python v${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: "requirements.txt"
- name: Virtual Environment Activation Definition - Windows
if: ${{ matrix.operating-system == 'windows-latest' }}
shell: bash
run: >
echo "SCUBAGOGGLES_ACTIVATE_VENV=.venv\Scripts\activate.ps1"
>> "$GITHUB_ENV"
- name: Virtual Environment Activation Definition - macOS or linux
if: ${{ matrix.operating-system != 'windows-latest' }}
shell: bash
run: >
echo "SCUBAGOGGLES_ACTIVATE_VENV=. .venv\bin\activate"
>> "$GITHUB_ENV"
- name: check variable
run: |
echo ${{ env.SCUBAGOGGLES_ACTIVATE_VENV }}
- name: Setup Dependencies (Windows)
if: ${{ matrix.operating-system == 'windows-latest' }}
uses: ./.github/actions/setup-dependencies-windows
with:
operating-system: "windows"
opa-version: ${{ needs.configuration.outputs.opa-version }}
python-version: ${{ matrix.python-version }}
- name: Setup Dependencies (macOS)
if: ${{ matrix.operating-system == 'macos-latest' }}
uses: ./.github/actions/setup-dependencies-macos
with:
operating-system: "macos"
opa-version: ${{ needs.configuration.outputs.opa-version }}
python-version: ${{ matrix.python-version }}
- name: Setup credentials for service account
id: create-json
uses: jsdaniell/[email protected]
with:
name: "credentials.json"
json: ${{ secrets.GWS_GITHUB_AUTOMATION_CREDS }}
- name: Run ScubaGoggles and check for correct output
run: |
${{ env.SCUBAGOGGLES_ACTIVATE_VENV }}
pytest ./scubagoggles/Testing/Functional/SmokeTests/ -vvv --subjectemail="${{ secrets.GWS_SUBJECT_EMAIL }}" --customerdomain="${{ secrets.GWS_DOMAIN }}"