|
1 | 1 | --- |
2 | 2 | name: CI |
3 | 3 |
|
4 | | -env: |
5 | | - ROLE_NAME: wcm_io_devops.jenkins_pipeline_library |
6 | | - |
7 | | -defaults: |
8 | | - run: |
9 | | - working-directory: 'wcm_io_devops.jenkins_pipeline_library' |
10 | | - |
11 | | -'on': |
12 | | - pull_request: |
| 4 | +on: |
13 | 5 | push: |
14 | | - branches: |
15 | | - - master |
| 6 | + branches: [ master ] |
| 7 | + pull_request: |
| 8 | + branches: [ master ] |
16 | 9 |
|
17 | 10 | jobs: |
18 | 11 |
|
19 | 12 | lint: |
20 | | - name: "Lint (${{ matrix.NAME }})" |
| 13 | + name: "lint & syntax check" |
21 | 14 | runs-on: ubuntu-latest |
22 | | - strategy: |
23 | | - matrix: |
24 | | - include: |
25 | | - - NAME: min_ansible_version |
26 | | - ANSIBLE_VERSION: "==2.7.*" |
27 | | - ANSIBLE_LINT_VERSION: "==4.2.*" |
28 | | - - NAME: latest |
29 | | - ANSIBLE_VERSION: "" |
30 | | - ANSIBLE_LINT_VERSION: "" |
31 | 15 |
|
32 | 16 | steps: |
33 | | - - name: Check out the codebase. |
| 17 | + - name: Checkout |
34 | 18 | uses: actions/checkout@v2 |
35 | | - with: |
36 | | - path: '${{ env.ROLE_NAME }}' |
37 | 19 |
|
38 | 20 | - name: Cache PIP |
39 | 21 | uses: actions/cache@v2 |
40 | 22 | with: |
41 | 23 | path: ~/.cache/pip |
42 | | - key: ${{ runner.os }}-pip-${{ matrix.ANSIBLE_VERSION }}-${{ hashFiles('**/requirements.txt') }} |
| 24 | + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} |
43 | 25 | restore-keys: | |
44 | | - ${{ runner.os }}-pip-${{ matrix.ANSIBLE_VERSION }}- |
45 | | -
|
46 | | - - name: Create ansible.cfg |
47 | | - run: "printf '[defaults]\nroles_path=./tests/requirements/:../' > ansible.cfg" |
| 26 | + ${{ runner.os }}-pip- |
48 | 27 |
|
49 | | - - name: Set up Python 3. |
50 | | - uses: actions/setup-python@v2 |
| 28 | + - name: Install role requirements |
| 29 | + uses: BSFishy/pip-action@v1 |
51 | 30 | with: |
52 | | - python-version: '3.9.x' |
| 31 | + requirements: "requirements.txt" |
53 | 32 |
|
54 | | - - name: Install pip tools. |
55 | | - run: | |
56 | | - pip3 install wheel --upgrade |
57 | | -
|
58 | | - - name: Install test dependencies. |
59 | | - run: > |
60 | | - pip3 install yamllint |
61 | | - ansible${{ matrix.ANSIBLE_VERSION }} |
62 | | - ansible-lint${{ matrix.ANSIBLE_LINT_VERSION }} |
63 | | - --upgrade |
64 | | -
|
65 | | - - name: Install role requirements. |
66 | | - run: | |
67 | | - pip3 install -r requirements.txt |
68 | | -
|
69 | | - - name: Install Galaxy requirements. |
70 | | - run: | |
71 | | - ansible-galaxy install -r tests/requirements.yml -p ./tests/requirements |
72 | | -
|
73 | | - - name: Lint code. |
74 | | - run: | |
75 | | - yamllint . |
76 | | - ansible-lint |
| 33 | + - name: Create ansible.cfg |
| 34 | + run: "printf '[defaults]\nroles_path=./tests/requirements/:../' > ansible.cfg" |
77 | 35 |
|
78 | | - - name: Test syntax. |
79 | | - run: | |
80 | | - ansible-playbook tests/test.yml -i tests/inventory --syntax-check |
| 36 | + - name: ansible-lint |
| 37 | + uses: ansible-community/ansible-lint-action@v6.2.1 |
81 | 38 |
|
82 | | - galaxy: |
83 | | - name: "Ansible Galaxy import" |
84 | | - needs: |
85 | | - - lint |
86 | | - if: github.ref == 'refs/heads/master' |
87 | | - runs-on: ubuntu-latest |
88 | | - steps: |
89 | | - - name: Trigger a new import on Galaxy. |
90 | | - uses: robertdebock/galaxy-action@affc5472cd0b08f64a51eafba49b08898c1bbeb8 |
| 39 | + - name: ansible-playbook syntax check |
| 40 | + uses: dawidd6/action-ansible-playbook@v2.5.0 |
91 | 41 | with: |
92 | | - galaxy_api_key: ${{ secrets.GALAXY_API_KEY }} |
| 42 | + playbook: tests/test.yml |
| 43 | + directory: "." |
| 44 | + requirements: tests/requirements.yml |
| 45 | + options: --syntax-check -i tests/inventory |
0 commit comments