-
Notifications
You must be signed in to change notification settings - Fork 0
96 lines (81 loc) · 2.66 KB
/
integration.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
name: Integration Tests
on:
pull_request:
push:
branches:
- main
concurrency:
group: ${{ github.head_ref || github.ref_name }}
# Avoid canceling to allow compute instances to be deleted
# by the "Cleanup test instances" step.
cancel-in-progress: false
env:
GCP_PROJECT_ID: ${{secrets.GCP_PROJECT_ID}}
OPAMP_SECRET_KEY: ${{secrets.OPAMP_SECRET_KEY}}
SSH_KEY_FILE: id_rsa
SSH_USER: ${{secrets.SSH_USER}}
GCP_AUTH_KIND: serviceaccount
jobs:
integration:
name: Molecule
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
scenario:
# scenario names are derived from molecule scenarios
# at molecule/
- "default"
steps:
- name: Checkout the codebase.
uses: actions/checkout@v2
- name: Install Gcloud SDK
uses: google-github-actions/[email protected]
- name: Authenticate to Google Cloud
uses: google-github-actions/[email protected]
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}
# when true, GOOGLE_APPLICATION_CREDENTIALS is set.
create_credentials_file: true
- name: Deploy SSH Keypair
run: |
echo "$SSH_PRIVATE_KEY" > id_rsa
echo "$SSH_PUBLIC_KEY" > id_rsa.pub
chmod -R 0600 id_rsa
chmod -R 0600 id_rsa.pub
shell: bash
env:
SSH_PRIVATE_KEY: ${{secrets.SSH_PRIVATE_KEY}}
SSH_PUBLIC_KEY: ${{secrets.SSH_PUBLIC_KEY}}
- name: Set up Python 3.
uses: actions/setup-python@v2
with:
python-version: '3.10'
# https://github.com/actions/cache/blob/main/examples.md#python---pip
- name: Cache Pip modules
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install Pip Modules.
run: |
pip3 install -r requirements.txt
echo "${HOME}/.local/bin" >> $GITHUB_PATH
- name: Install Galaxy Modules
run: |
ansible-galaxy collection install google.cloud
ansible-galaxy collection install community.crypto
- name: Lint.
run: |
molecule syntax -s ${{ matrix.scenario }}
- name: Converge.
run: molecule converge -s ${{ matrix.scenario }}
- name: Check Idempotence.
run: molecule idempotence -s ${{ matrix.scenario }}
- name: Verify.
run: molecule verify -s ${{ matrix.scenario }}
- name: Cleanup test instances.
run: molecule destroy -s ${{ matrix.scenario }}
if: ${{ always() }}