summaryrefslogtreecommitdiffstats
path: root/.github/workflows/ci.yml
blob: 80eaaccc89a493067ec3fd23908d2dae8039e011 (plain) (blame)
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
---
name: "CI"
'on': ["push", "pull_request"]
jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: "3.x"
      - name: Install dependencies
        run: pip3 install yamllint ansible-lint
      - name: Copy example files
        run: |
          # Use example files for testing instead of encrypted files
          for f in host_vars/*.example; do mv "$f" "$(echo "$f" | sed s/\.example//)"; done
      - name: Run
        run: |
          yamllint .
          ansible-lint

  playbook:
    strategy:
      fail-fast: false
      matrix:
        molecule_distro:
          - distro: archlinux
            platform: "linux/amd64"
            runs_on: "ubuntu-latest"
          - distro: ubuntu
            platform: "linux/amd64"
            runs_on: "ubuntu-latest"
          - distro: raspberrypi
            platform: "linux/arm64/v8"
            runs_on: "ubuntu-24.04-arm"
    runs-on: ${{ matrix.molecule_distro.runs_on }}
    steps:
      - uses: actions/checkout@v4
        with:
          repository: "a14m/ansible-distro-install"
          path: "ansible-distro-install"
      - uses: actions/checkout@v4
        with:
          repository: "a14m/ansible-distro-configure"
          path: "ansible-distro-configure"
      - uses: actions/setup-python@v5
        with:
          python-version: "3.x"
      - name: Install dependencies
        run: pip3 install ansible molecule molecule-plugins[docker]
      - name: Copy distro install example files
        run: |
          # Use example files for testing instead of encrypted files
          cd ansible-distro-install &&
          for f in host_vars/*.example; do mv "$f" "$(echo "$f" | sed s/\.example//)"; done
      - name: Copy distro configure example files
        run: |
          # Use example files for testing instead of encrypted files
          cd ansible-distro-configure &&
          for f in group_vars/*.example; do mv "$f" "$(echo "$f" | sed s/\.example//)"; done &&
          for f in host_vars/*.example; do mv "$f" "$(echo "$f" | sed s/\.example//)"; done
      - name: Run
        env:
          PY_COLORS: 1
          ANSIBLE_FORCE_COLOR: 1
        run: >-
          cd ansible-distro-install &&
          molecule --version &&
          ansible --version &&
          MOLECULE_COMMAND=${{ matrix.molecule_distro.command }}
          MOLECULE_PLATFORM=${{ matrix.molecule_distro.platform }}
          MOLECULE_DISTRO=${{ matrix.molecule_distro.distro }}
          molecule test