-
Notifications
You must be signed in to change notification settings - Fork 2
110 lines (105 loc) · 3.93 KB
/
ansible-test.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
104
105
106
107
108
109
110
---
name: Ansible collection
'on':
push:
workflow_dispatch:
jobs:
lint:
runs-on: ubuntu-18.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install yamllint
run: sudo apt install yamllint
- name: Lint yaml
run: yamllint .
test:
runs-on: ubuntu-latest
env:
ANSIBLE_FORCE_COLOR: "True"
steps:
- name: Log github.ref
run: echo ${{ github.ref }}
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8==4.0.0 pytest==6.2.4
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Install kernel extra modules
run: sudo apt-get install -y linux-modules-extra-$(uname -r)
- name: Sanity tests with dependencies
run: ansible-test sanity --requirements --python 3.8
working-directory: ansible_collections/amarao/ip
- name: Unit tests with dependencies
run: ansible-test units --requirements --python 3.8
working-directory: ansible_collections/amarao/ip
- name: Integration tests with dependencies
run: ansible-test integration --requirements --python 3.8 --local --allow-root
working-directory: ansible_collections/amarao/ip
- name: Cleanup
run: rm -fr ansible_collections/amarao/ip/tests/output ansible_collections/amarao/ip/.pytest_cache
- name: Try-build by ansible-galaxy
run: ansible-galaxy collection build
working-directory: ansible_collections/amarao/ip
- name: Lint changelog
run: antsibull-lint changelog-yaml ansible_collections/amarao/ip/changelogs/changelog.yaml
build:
runs-on: ubuntu-latest
needs: test
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Remove tests from final distribution
run: rm -r tests/
working-directory: ansible_collections/amarao/ip
- name: Build collection
run: ansible-galaxy collection build
working-directory: ansible_collections/amarao/ip
- name: Extract version
id: version
run: |
version=$(cat galaxy.yml |grep ^version|awk '{print $2}')
echo "::set-output name=version::$version"
working-directory: ansible_collections/amarao/ip
- name: Print artifact info
run: |
ls -la amarao-ip-${{ steps.version.outputs.version }}.tar.gz
sha512sum amarao-ip-${{ steps.version.outputs.version }}.tar.gz
tar tzf amarao-ip-${{ steps.version.outputs.version }}.tar.gz
working-directory: ansible_collections/amarao/ip
- name: Save artifact
if: ${{ endsWith(github.ref, steps.version.outputs.version) }}
uses: actions/upload-artifact@v2
with:
name: collection
path: ansible_collections/amarao/ip/amarao-ip-${{ steps.version.outputs.version }}.tar.gz
publish:
runs-on: ubuntu-latest
needs: build
if: ${{ endsWith(github.ref, needs.build.outputs.version) }}
steps:
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: collection
- name: Debug output
run: ls -la amarao-ip-${{needs.build.outputs.version }}.tar.gz
- name: Upload collection to galaxy
run: ansible-galaxy collection publish amarao-ip-${{ needs.build.outputs.version }}.tar.gz --api-key="${{ secrets.GALAXY_API_TOKEN }}"