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