|
| 1 | +--- |
| 2 | +name: "CI" |
| 3 | +on: # yamllint disable |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - "develop" |
| 7 | + - "main" |
| 8 | + pull_request: |
| 9 | + release: |
| 10 | + types: [published] |
| 11 | + schedule: |
| 12 | + - cron: "20 3 * * 1" |
| 13 | + |
| 14 | +jobs: |
| 15 | + lint: |
| 16 | + runs-on: "ubuntu-20.04" |
| 17 | + steps: |
| 18 | + - name: "Check out repository code" |
| 19 | + uses: "actions/checkout@v2" |
| 20 | + - name: "Install invoke" |
| 21 | + run: "pip install -U pip && pip install invoke" |
| 22 | + - name: "Linting" |
| 23 | + run: "invoke lint" |
| 24 | + test: |
| 25 | + runs-on: "ubuntu-20.04" |
| 26 | + strategy: |
| 27 | + fail-fast: true |
| 28 | + matrix: |
| 29 | + python-version: ["3.7", "3.8", "3.9"] |
| 30 | + steps: |
| 31 | + - name: "Check out repository code" |
| 32 | + uses: "actions/checkout@v2" |
| 33 | + - name: "Install invoke" |
| 34 | + run: "pip install -U pip && pip install invoke" |
| 35 | + - name: "Tests" |
| 36 | + run: "invoke unit" |
| 37 | + needs: |
| 38 | + - "lint" |
| 39 | + integration: |
| 40 | + runs-on: "ubuntu-20.04" |
| 41 | + strategy: |
| 42 | + fail-fast: false |
| 43 | + matrix: |
| 44 | + # Need to check what is needed for the integration step |
| 45 | + # python-version: ["3.7", "3.8", "3.9"] |
| 46 | + # ansible-release: ["base", "core"] |
| 47 | + include: |
| 48 | + - python-version: "3.8" |
| 49 | + ansible-release: "base" # Ansible 2.10 |
| 50 | + - python-version: "3.8" |
| 51 | + ansible-release: "2.11" |
| 52 | + - python-version: "3.8" |
| 53 | + ansible-release: "core" |
| 54 | + steps: |
| 55 | + - name: "Check out repository code" |
| 56 | + uses: "actions/checkout@v2" |
| 57 | + - name: "Install invoke" |
| 58 | + run: "pip install -U pip && pip install invoke" |
| 59 | + - name: "Install poetry" |
| 60 | + if: "${{ matrix.ansible-release == '2.11' }}" |
| 61 | + run: "pip install poetry==1.4.2" |
| 62 | + - name: "Remove ansible-base" |
| 63 | + if: "${{ matrix.ansible-release == '2.11' }}" |
| 64 | + run: "poetry remove ansible-base" |
| 65 | + - name: "Add ansible-core" |
| 66 | + if: "${{ matrix.ansible-release == '2.11' }}" |
| 67 | + run: "poetry add ansible-core@~2.11" |
| 68 | + - name: "Install poetry" |
| 69 | + if: "${{ matrix.ansible-release == '2.9' }}" |
| 70 | + run: "pip install poetry==1.4.2" |
| 71 | + - name: "Remove ansible-base" |
| 72 | + if: "${{ matrix.ansible-release == '2.9' }}" |
| 73 | + run: "poetry remove ansible-base" |
| 74 | + - name: "Add Ansible 2.9" |
| 75 | + if: "${{ matrix.ansible-release == '2.9' }}" |
| 76 | + run: "poetry add ansible@~2.9" |
| 77 | + - name: "Install poetry" |
| 78 | + if: "${{ matrix.ansible-release == '2.12' }}" |
| 79 | + run: "pip install poetry==1.4.2" |
| 80 | + - name: "Remove ansible-base" |
| 81 | + if: "${{ matrix.ansible-release == '2.12' }}" |
| 82 | + run: "poetry remove ansible-base" |
| 83 | + - name: "Add Ansible 2.12" |
| 84 | + if: "${{ matrix.ansible-release == '2.12' }}" |
| 85 | + run: "poetry add ansible-core@~2.12 --python ^${{ matrix.python-version }}" |
| 86 | + - name: "Start containers" |
| 87 | + run: "invoke start" |
| 88 | + - name: "Tests" |
| 89 | + run: "invoke integration" |
| 90 | + needs: |
| 91 | + - "test" |
| 92 | + publish_github: |
| 93 | + name: "Publish to GitHub" |
| 94 | + runs-on: "ubuntu-20.04" |
| 95 | + if: "startsWith(github.ref, 'refs/tags/v')" |
| 96 | + steps: |
| 97 | + - name: "Check out repository code" |
| 98 | + uses: "actions/checkout@v2" |
| 99 | + - name: "Set up Python" |
| 100 | + uses: "actions/setup-python@v2" |
| 101 | + with: |
| 102 | + python-version: "3.9" |
| 103 | + - name: "Install Python Packages" |
| 104 | + run: "pip install ansible-core" |
| 105 | + - name: "Build the collection" |
| 106 | + run: "ansible-galaxy collection build --output-path build" |
| 107 | + - name: "Upload binaries to release" |
| 108 | + uses: "svenstaro/upload-release-action@v2" |
| 109 | + with: |
| 110 | + repo_token: "${{ secrets.NTC_GITHUB_TOKEN }}" |
| 111 | + file: "build/*" |
| 112 | + tag: "${{ github.ref }}" |
| 113 | + overwrite: true |
| 114 | + file_glob: true |
| 115 | + needs: |
| 116 | + - "integration" |
| 117 | + publish_galaxy: |
| 118 | + name: "Publish to Ansible Galaxy" |
| 119 | + runs-on: "ubuntu-20.04" |
| 120 | + if: "startsWith(github.ref, 'refs/tags/v')" |
| 121 | + steps: |
| 122 | + - name: "Check out repository code" |
| 123 | + uses: "actions/checkout@v2" |
| 124 | + - name: "Set up Python" |
| 125 | + uses: "actions/setup-python@v2" |
| 126 | + with: |
| 127 | + python-version: "3.9" |
| 128 | + - name: "Install Python Packages" |
| 129 | + run: "pip install ansible-core" |
| 130 | + - name: "Build the collection" |
| 131 | + run: "ansible-galaxy collection build --output-path build" |
| 132 | + - name: "Publish the collection" |
| 133 | + run: "ansible-galaxy collection publish build/* --api-key=${{ secrets.GALAXY_API_TOKEN }}" |
| 134 | + needs: |
| 135 | + - "integration" |
0 commit comments