Skip to content

Commit 3ad25b7

Browse files
authored
Add examples run to workflow. (#155)
CI run examples in --check mode Fix some of the examples.
1 parent b71efe3 commit 3ad25b7

File tree

5 files changed

+114
-16
lines changed

5 files changed

+114
-16
lines changed

.github/workflows/integ-test.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,75 @@ jobs:
9898
)" >> $GITHUB_OUTPUT
9999
if: "${{ github.event.inputs.integ_tests_include || github.event.schedule }}"
100100

101+
examples-matrix:
102+
runs-on: [ ubuntu-latest ]
103+
container: python:3.10-slim-buster
104+
env:
105+
DEBIAN_FRONTEND: noninteractive
106+
ANSIBLE_COLLECTIONS_PATH: /work-dir
107+
outputs:
108+
matrix: ${{ steps.set-matrix.outputs.matrix }}
109+
steps:
110+
- name: Checkout
111+
uses: actions/checkout@v3
112+
- run: apt update
113+
- run: apt install -y jq
114+
- run: mkdir -p $WORKDIR
115+
- run: cp -a ./ $WORKDIR
116+
# A few files are not an example playbook:
117+
# hypercore_inventory.yml - inventory example
118+
# cloud-init-user-data-example.yml - cloud-init user-data example
119+
- id: set-matrix
120+
shell: bash
121+
run: |-
122+
echo "matrix=$(
123+
ls -r $WORKDIR/examples |
124+
grep -v -E "^README.md$|^hypercore_inventory.yml$|^cloud-init-user-data-example.yml$" |
125+
jq -R -s -c 'split("\n")[:-1]'
126+
)" >> $GITHUB_OUTPUT
127+
if: "${{ github.event.inputs || github.event.schedule }}"
128+
129+
examples-run:
130+
needs:
131+
- examples-matrix
132+
runs-on: [ self-hosted2 ]
133+
container: python:3.10-slim-buster
134+
env:
135+
DEBIAN_FRONTEND: noninteractive
136+
strategy:
137+
fail-fast: false
138+
matrix:
139+
ansible: [ 2.13.0 ]
140+
example_name: ${{ fromJson(needs.examples-matrix.outputs.matrix) }}
141+
steps:
142+
- name: Checkout
143+
uses: actions/checkout@v3
144+
- run: pip3 install -r sanity.requirements -r test.requirements -r docs.requirements
145+
- run: apt update
146+
- run: apt install -y git make
147+
- run: apt install -y genisoimage qemu-utils jq
148+
- run: pip install yq
149+
- run: pip install ansible-core~=${{ matrix.ansible }}
150+
- run: mkdir -p $WORKDIR
151+
- run: cp -a ./ $WORKDIR
152+
- run: cd $WORKDIR && ansible-galaxy collection install community.crypto community.general
153+
- run: cd $WORKDIR && ansible-galaxy collection list
154+
- run: |
155+
cd $WORKDIR
156+
echo "${{ vars.CI_CONFIG_HC_IP50 }}" > tests/integration/integration_config.yml
157+
cat tests/integration/integration_config.yml
158+
echo "sc_password: ${{ secrets.CI_CONFIG_HC_IP50_SC_PASSWORD }}" >> tests/integration/integration_config.yml
159+
echo "smb_password: ${{ secrets.CI_CONFIG_HC_IP50_SMB_PASSWORD }}" >> tests/integration/integration_config.yml
160+
echo "sc_replication_dest_password: ${{ secrets.CI_CONFIG_HC_IP50_SC_REPLICATION_DEST_PASSWORD }}" >> tests/integration/integration_config.yml
161+
ls -al tests/integration/integration_config.yml
162+
- run: |
163+
cd $WORKDIR
164+
eval export SC_HOST=$(cat tests/integration/integration_config.yml | yq '.sc_host')
165+
eval export SC_USERNAME=$(cat tests/integration/integration_config.yml | yq '.sc_username')
166+
eval export SC_PASSWORD=$(cat tests/integration/integration_config.yml | yq '.sc_password')
167+
eval export SC_TIMEOUT=$(cat tests/integration/integration_config.yml | yq '.sc_timeout')
168+
ansible-playbook --check examples/${{ matrix.example_name }}
169+
101170
integ:
102171
needs:
103172
- integ-matrix
@@ -139,6 +208,7 @@ jobs:
139208
ls -al tests/integration/integration_config.yml
140209
- run: cd $WORKDIR && ansible-test integration --local ${{ matrix.test_name }}
141210

211+
142212
replica_cleanup:
143213
needs:
144214
- integ

examples/time_server.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
---
2-
- name: Modify current NTP Time Server entries (in HyperCore API settings)
3-
scale_computing.hypercore.time_server:
4-
source: pool.ntp.org # must be set if not already present in existing entries
2+
- name: Example time_server module
3+
hosts: localhost
4+
connection: local
5+
gather_facts: false
6+
vars:
7+
source: pool.ntp.org
8+
9+
tasks:
10+
- name: Modify current NTP Time Server entries (in HyperCore API settings)
11+
scale_computing.hypercore.time_server:
12+
source: "{{ source }}" # must be set if not already present in existing entries

examples/time_server_info.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
---
2-
- name: List current Time Server entries
3-
scale_computing.hypercore.time_server_info:
4-
register: time_server_info
5-
- ansible.builtin.debug:
6-
msg: "{{ time_server_info }}"
2+
- name: Example time_server_info module
3+
hosts: localhost
4+
connection: local
5+
gather_facts: false
6+
7+
tasks:
8+
- name: List current Time Server entries
9+
scale_computing.hypercore.time_server_info:
10+
register: time_server_info
11+
- ansible.builtin.debug:
12+
msg: "{{ time_server_info }}"

examples/time_zone.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
---
2-
- name: Modify current Time Zone entries (in HyperCore API settings)
3-
scale_computing.hypercore.time_zone:
4-
zone: US/Eastern # must be set if not already present in existing entries
2+
- name: Example time_zone module
3+
hosts: localhost
4+
connection: local
5+
gather_facts: false
6+
vars:
7+
zone: US/Eastern
8+
9+
tasks:
10+
- name: Modify current Time Zone entries (in HyperCore API settings)
11+
scale_computing.hypercore.time_zone:
12+
zone: "{{ zone }}" # must be set if not already present in existing entries

examples/time_zone_info.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
---
2-
- name: List current Time Zone entries
3-
- scale_computing.hypercore.time_zone_info:
4-
register: time_zone_info
5-
- ansible.builtin.debug:
6-
msg: "{{ time_zone_info }}"
2+
- name: Example time_zone_info module
3+
hosts: localhost
4+
connection: local
5+
gather_facts: false
6+
7+
tasks:
8+
- name: List current Time Zone entries
9+
- scale_computing.hypercore.time_zone_info:
10+
register: time_zone_info
11+
- ansible.builtin.debug:
12+
msg: "{{ time_zone_info }}"

0 commit comments

Comments
 (0)