Skip to content
This repository was archived by the owner on May 17, 2022. It is now read-only.

Commit 89b83e1

Browse files
committed
ci: update test workflow
1 parent cccdb04 commit 89b83e1

File tree

2 files changed

+89
-81
lines changed

2 files changed

+89
-81
lines changed

.github/workflows/test.yml

Lines changed: 87 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,26 @@ env:
1111
DOMAIN_NAME: "pr-${{ github.run_id }}-caddy"
1212
DOMAIN_SUFFIX: "test.stackhead.io"
1313

14+
# You should not need to change anything below.
15+
1416
jobs:
1517
smoke:
1618
name: Smoketest test-tf-generation
1719
runs-on: ubuntu-latest
1820
steps:
1921
- uses: actions/checkout@v2
20-
- name: Install Ansible v2.10 alpha (GH actions currently uses 2.9)
21-
run: ANSIBLE_SKIP_CONFLICT_CHECK=1 pip install --user ansible==2.10.0a9 && ansible --version
22+
- name: Remove Python 2 and old Ansible 2.9 version
23+
run: sudo apt purge python ansible -y
24+
- name: Set up Python 3
25+
uses: actions/setup-python@v2
26+
with:
27+
python-version: '3.x'
28+
- name: Install Ansible v2.10.3 (GH actions currently uses 2.9)
29+
run: pip install ansible==2.10.3
30+
- name: Print Ansible and Python version
31+
run: ansible --version && python --version
2232
- name: Get latest StackHead version
2333
run: ansible-galaxy collection install git+https://github.com/getstackhead/stackhead.git,next -f
24-
- run: pip install -r ./requirements/pip.txt
2534
- run: ansible-playbook ./__tests__/test-tf-generation.yml
2635

2736
checkLabel:
@@ -36,80 +45,79 @@ jobs:
3645
needs: checkLabel
3746
runs-on: ubuntu-latest
3847
if: github.event.pull_request.draft == false
39-
env:
40-
INVENTORY_PATH: __tests__/inventory.yml
4148
steps:
42-
- uses: actions/checkout@v2
43-
- name: Set up Python 3
44-
uses: actions/setup-python@v2
45-
with:
46-
python-version: '3.x'
47-
- name: Uninstall old Ansible
48-
run: ansible --version && sudo apt purge ansible -y
49-
- name: Install Ansible v2.10.3 (GH actions currently uses 2.9)
50-
run: sudo python -m pip install ansible==2.10.3 && ansible --version
51-
- run: pip -V && pip install -r ./requirements/pip.txt
52-
- uses: webfactory/[email protected]
53-
with:
54-
ssh-private-key: "${{ secrets.SSH_PRIVATE_KEY }}"
55-
- name: Setup Hetzner server
56-
id: setup_server
57-
uses: saitho/[email protected]
58-
with:
59-
action: create
60-
server_name: "${{ env.DOMAIN_NAME }}"
61-
server_image: ubuntu-18.04
62-
server_location: fsn1
63-
server_ssh_key_name: gh-actions
64-
wait_for_ssh: 1
65-
env:
66-
API_TOKEN: ${{ secrets.HETZNER_TOKEN }}
67-
- name: Add DNS record
68-
uses: saitho/create-dns-record@patch-1
69-
with:
70-
type: "A"
71-
name: "${{ env.DOMAIN_NAME }}.${{ env.DOMAIN_SUFFIX }}"
72-
content: "${{ steps.setup_server.outputs.hcloud_server_created_ipv4 }}"
73-
ttl: 1
74-
proxied: 0
75-
token: "${{ secrets.CLOUDFLARE_TOKEN }}"
76-
zone: "${{ secrets.CLOUDFLARE_ZONE }}"
77-
- name: Add DNS record for subdomain
78-
uses: saitho/create-dns-record@patch-1
79-
with:
80-
type: "A"
81-
name: "sub.${{ env.DOMAIN_NAME }}.${{ env.DOMAIN_SUFFIX }}"
82-
content: "${{ steps.setup_server.outputs.hcloud_server_created_ipv4 }}"
83-
ttl: 1
84-
proxied: 0
85-
token: "${{ secrets.CLOUDFLARE_TOKEN }}"
86-
zone: "${{ secrets.CLOUDFLARE_ZONE }}"
87-
- uses: getstackhead/stackhead/actions/integration-test@next
88-
with:
89-
ipaddress: ${{ steps.setup_server.outputs.hcloud_server_created_ipv4 }}
90-
domain: '${{ env.DOMAIN_NAME }}.${{ env.DOMAIN_SUFFIX }}'
91-
domain2: 'sub.${{ env.DOMAIN_NAME }}.${{ env.DOMAIN_SUFFIX }}'
92-
webserver: '${{ env.WEBSERVER }}'
93-
rolename: '${{ env.ROLE_NAME }}'
94-
- name: Remove DNS record
95-
uses: saitho/delete-dns-record@saitho-patch-1
96-
if: always()
97-
with:
98-
name: "${{ env.DOMAIN_NAME }}.${{ env.DOMAIN_SUFFIX }}"
99-
token: "${{ secrets.CLOUDFLARE_TOKEN }}"
100-
zone: "${{ secrets.CLOUDFLARE_ZONE }}"
101-
- name: Remove DNS record for subdomain
102-
uses: saitho/delete-dns-record@saitho-patch-1
103-
if: always()
104-
with:
105-
name: "sub.${{ env.DOMAIN_NAME }}.${{ env.DOMAIN_SUFFIX }}"
106-
token: "${{ secrets.CLOUDFLARE_TOKEN }}"
107-
zone: "${{ secrets.CLOUDFLARE_ZONE }}"
108-
- name: Remove Hetzner server
109-
uses: saitho/[email protected]
110-
if: always()
111-
with:
112-
action: remove
113-
server_id: "${{ steps.setup_server.outputs.hcloud_server_id }}"
114-
env:
115-
API_TOKEN: ${{ secrets.HETZNER_TOKEN }}
49+
- uses: actions/checkout@v2
50+
- name: Remove Python 2 and old Ansible 2.9 version
51+
run: sudo apt purge python ansible -y
52+
- name: Set up Python 3
53+
uses: actions/setup-python@v2
54+
with:
55+
python-version: '3.x'
56+
- name: Install Ansible v2.10.3 (GH actions currently uses 2.9)
57+
run: pip install ansible==2.10.3
58+
- name: Print Ansible and Python version
59+
run: ansible --version && python --version
60+
- uses: webfactory/[email protected]
61+
with:
62+
ssh-private-key: "${{ secrets.SSH_PRIVATE_KEY }}"
63+
- name: Setup Hetzner server
64+
id: setup_server
65+
uses: saitho/[email protected]
66+
with:
67+
action: create
68+
server_name: "${{ env.DOMAIN_NAME }}"
69+
server_image: ubuntu-18.04
70+
server_location: fsn1
71+
server_ssh_key_name: gh-actions
72+
wait_for_ssh: 1
73+
env:
74+
API_TOKEN: ${{ secrets.HETZNER_TOKEN }}
75+
- name: Add DNS record
76+
uses: saitho/create-dns-record@patch-1
77+
with:
78+
type: "A"
79+
name: "${{ env.DOMAIN_NAME }}.${{ env.DOMAIN_SUFFIX }}"
80+
content: "${{ steps.setup_server.outputs.hcloud_server_created_ipv4 }}"
81+
ttl: 1
82+
proxied: 0
83+
token: "${{ secrets.CLOUDFLARE_TOKEN }}"
84+
zone: "${{ secrets.CLOUDFLARE_ZONE }}"
85+
- name: Add DNS record for subdomain
86+
uses: saitho/create-dns-record@patch-1
87+
with:
88+
type: "A"
89+
name: "sub.${{ env.DOMAIN_NAME }}.${{ env.DOMAIN_SUFFIX }}"
90+
content: "${{ steps.setup_server.outputs.hcloud_server_created_ipv4 }}"
91+
ttl: 1
92+
proxied: 0
93+
token: "${{ secrets.CLOUDFLARE_TOKEN }}"
94+
zone: "${{ secrets.CLOUDFLARE_ZONE }}"
95+
- uses: getstackhead/stackhead/actions/integration-test@next
96+
with:
97+
ipaddress: ${{ steps.setup_server.outputs.hcloud_server_created_ipv4 }}
98+
domain: '${{ env.DOMAIN_NAME }}.${{ env.DOMAIN_SUFFIX }}'
99+
domain2: 'sub.${{ env.DOMAIN_NAME }}.${{ env.DOMAIN_SUFFIX }}'
100+
webserver: '${{ env.WEBSERVER }}'
101+
rolename: '${{ env.ROLE_NAME }}'
102+
- name: Remove DNS record
103+
uses: saitho/delete-dns-record@saitho-patch-1
104+
if: always()
105+
with:
106+
name: "${{ env.DOMAIN_NAME }}.${{ env.DOMAIN_SUFFIX }}"
107+
token: "${{ secrets.CLOUDFLARE_TOKEN }}"
108+
zone: "${{ secrets.CLOUDFLARE_ZONE }}"
109+
- name: Remove DNS record for subdomain
110+
uses: saitho/delete-dns-record@saitho-patch-1
111+
if: always()
112+
with:
113+
name: "sub.${{ env.DOMAIN_NAME }}.${{ env.DOMAIN_SUFFIX }}"
114+
token: "${{ secrets.CLOUDFLARE_TOKEN }}"
115+
zone: "${{ secrets.CLOUDFLARE_ZONE }}"
116+
- name: Remove Hetzner server
117+
uses: saitho/[email protected]
118+
if: always()
119+
with:
120+
action: remove
121+
server_id: "${{ steps.setup_server.outputs.hcloud_server_id }}"
122+
env:
123+
API_TOKEN: ${{ secrets.HETZNER_TOKEN }}

__tests__/test-tf-generation.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
with_items: "{{ app_config.domains }}"
1212
- block:
1313
- name: Generate Caddy Terraform file
14-
import_tasks: "../tasks/caddy_steps/generate-serverconfig-tf.yml"
14+
import_tasks: "{{ module_role_path | default(role_path) }}/tasks/caddy_steps/generate-serverconfig-tf.yml"
1515
- name: Generate Caddyfile
16-
import_tasks: "../tasks/caddy_steps/generate-caddyfile-tf.yml"
16+
import_tasks: "{{ module_role_path | default(role_path) }}/tasks/caddy_steps/generate-caddyfile-tf.yml"
1717
vars:
1818
module_role_path: ".."
1919
caddy_root: "."

0 commit comments

Comments
 (0)