-
Notifications
You must be signed in to change notification settings - Fork 0
103 lines (82 loc) · 2.61 KB
/
ci.yaml
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
name: CI
on:
push:
branches: [master]
pull_request:
branches: [master]
defaults:
run:
shell: bash
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install pre-commit
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade pre-commit
ansible-galaxy collection install --force ansible.posix
ansible-galaxy collection install --force community.postgresql
- name: Run pre-commit
run: |
python -m pre_commit run --all-files --show-diff-on-failure
python:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install pytest / Ruff
run: |
python -m pip install pytest ruff
- name: Run Python linter
run: |
ruff format --check
ruff check
- name: Run Python tests
run: |
pushd roles/postgres/files
PATH=$PWD:$PATH pytest -v .
popd
ansible:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Ansible
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade ansible
ansible-galaxy collection install --force ansible.posix
ansible-galaxy collection install --force community.postgresql
- name: Remove pre-baked PostgreSQL
run:
# Existing pre-baked PostgreSQL installation may conflict with the
# PostgreSQL installed by our playbook. We better remove it for a
# greater good.
sudo apt purge 'postgresql-*'
- name: Create block storage device (volume)
run: |
VOLUME_DEVICE="$(losetup -f)"
VOLUME_IMAGE="${{ runner.temp }}/diskimage"
dd if=/dev/zero of=$VOLUME_IMAGE bs=1M count=1024
sudo losetup $VOLUME_DEVICE $VOLUME_IMAGE
echo "uri=$VOLUME_DEVICE" >> $GITHUB_OUTPUT
id: volume-device
- name: Add server names to /etc/hosts
run: |
echo "127.0.0.1 xsnippet.local" | sudo tee -a /etc/hosts
echo "127.0.0.1 api.xsnippet.local" | sudo tee -a /etc/hosts
- name: Run the playbook
run: |
ansible-playbook \
-vvv \
-e volume_device="${{ steps.volume-device.outputs.uri }}" \
--inventory inventories/ci \
site.yml