|
| 1 | +--- |
| 2 | +name: collection-tests |
| 3 | +"on": |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + distros: |
| 7 | + required: false |
| 8 | + description: a list of debian based distribution |
| 9 | + type: string |
| 10 | + default: "['debian12', 'ubuntu2404']" |
| 11 | + nc_versions: |
| 12 | + required: false |
| 13 | + description: a list of nextcloud server version |
| 14 | + type: string |
| 15 | + default: "['latest']" |
| 16 | +env: |
| 17 | + PYTHON_VERSION: '3.12' |
| 18 | +jobs: |
| 19 | + lint: |
| 20 | + name: linters |
| 21 | + runs-on: ubuntu-latest |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@v4 |
| 24 | + with: |
| 25 | + fetch-depth: 0 |
| 26 | + - name: Run ansible-lint |
| 27 | + uses: ansible/ansible-lint@v25 |
| 28 | + |
| 29 | + - name: Set up Python 3. |
| 30 | + uses: actions/setup-python@v5 |
| 31 | + with: |
| 32 | + python-version: ${{ env.PYTHON_VERSION }} |
| 33 | + |
| 34 | + - name: Upgrade pip |
| 35 | + run: | |
| 36 | + pip install --constraint=.github/workflows/constraints.txt pip |
| 37 | + pip --version |
| 38 | +
|
| 39 | + - name: Upgrade yamllint |
| 40 | + run: | |
| 41 | + pip install --constraint=.github/workflows/constraints.txt yamllint |
| 42 | +
|
| 43 | + - name: Lint code. |
| 44 | + run: | |
| 45 | + yamllint -c .yamllint.yml . |
| 46 | +
|
| 47 | + ansible-tests: |
| 48 | + name: ansible-tests |
| 49 | + needs: |
| 50 | + - lint |
| 51 | + runs-on: ubuntu-latest |
| 52 | + defaults: |
| 53 | + run: |
| 54 | + working-directory: ./code/ansible_collections/nextcloud/admin/ |
| 55 | + steps: |
| 56 | + - name: Checkout repository |
| 57 | + uses: actions/checkout@v4 |
| 58 | + with: |
| 59 | + path: ./code/ansible_collections/nextcloud/admin/ |
| 60 | + fetch-depth: 0 |
| 61 | + - name: Set up Python |
| 62 | + uses: actions/setup-python@v5 |
| 63 | + with: |
| 64 | + python-version: ${{ env.PYTHON_VERSION }} |
| 65 | + |
| 66 | + - name: Install dependencies |
| 67 | + run: | |
| 68 | + python -m pip install --constraint=.github/workflows/constraints.txt --upgrade pip |
| 69 | + pip install --constraint=.github/workflows/constraints.txt ansible pytest |
| 70 | +
|
| 71 | + - name: Run units tests |
| 72 | + run: | |
| 73 | + ansible-test units --requirements --docker |
| 74 | +
|
| 75 | + - name: Run sanity tests |
| 76 | + run: | |
| 77 | + ansible-test sanity --requirements --docker |
| 78 | +
|
| 79 | + molecule_test: |
| 80 | + defaults: |
| 81 | + run: |
| 82 | + working-directory: "nextcloud.ansible-collection-nextcloud-admin" |
| 83 | + name: molecule-test |
| 84 | + runs-on: ubuntu-latest |
| 85 | + strategy: |
| 86 | + fail-fast: false |
| 87 | + matrix: |
| 88 | + distros: ${{ fromJson(inputs.distros)}} |
| 89 | + nc_versions: ${{ fromJson(inputs.nc_versions)}} |
| 90 | + steps: |
| 91 | + - name: Check out the repository |
| 92 | + uses: actions/checkout@v4 |
| 93 | + with: |
| 94 | + path: "nextcloud.ansible-collection-nextcloud-admin" |
| 95 | + |
| 96 | + - name: Set up Python |
| 97 | + uses: actions/setup-python@v5 |
| 98 | + with: |
| 99 | + python-version: ${{ env.PYTHON_VERSION }} |
| 100 | + |
| 101 | + - name: Upgrade pip |
| 102 | + run: | |
| 103 | + python3 -m pip install --constraint=.github/workflows/constraints.txt pip |
| 104 | + python3 -m pip --version |
| 105 | +
|
| 106 | + - name: Install test dependencies |
| 107 | + run: | |
| 108 | + python3 -m pip install --constraint=.github/workflows/constraints.txt ansible 'molecule-plugins[docker]' docker netaddr PyMySQL |
| 109 | +
|
| 110 | + - name: precreate mysql database |
| 111 | + run: | |
| 112 | + sudo systemctl start mysql.service |
| 113 | + ansible localhost -m community.mysql.mysql_db -a "name=nc login_user=root login_password=root state=present" |
| 114 | + ansible localhost -m community.mysql.mysql_user -a "name=nc password=nc priv=nc.*:ALL login_user=root login_password=root state=present" |
| 115 | +
|
| 116 | + - name: Run Molecule tests |
| 117 | + run: molecule test |
| 118 | + env: |
| 119 | + PY_COLORS: "1" |
| 120 | + ANSIBLE_FORCE_COLOR: "1" |
| 121 | + MOLECULE_DISTRO: ${{ matrix.distros }} |
| 122 | + MOLECULE_NC: ${{ matrix.nc_versions }} |
0 commit comments