blob: 1736b416ff444eae3c526046c3afd8f53bb1a1cb [file] [log] [blame]
Mohammed Nasera4e52902022-08-30 00:20:05 -04001name: test
2on:
3 pull_request: {}
Mohammed Nasera4e52902022-08-30 00:20:05 -04004
5jobs:
Mohammed Naser9a5ff202022-09-07 15:56:48 -04006 build-prometheus-ethtool-exporter:
Mohammed Naserd4e634d2022-08-30 18:46:03 -04007 runs-on: ubuntu-latest
Mohammed Naserd4e634d2022-08-30 18:46:03 -04008 steps:
Mohammed Naser88cb2762023-01-18 03:28:21 +00009 - uses: actions/checkout@v3
Mohammed Naser09d8ea82022-09-03 19:16:18 -040010 with:
Mohammed Naser9a5ff202022-09-07 15:56:48 -040011 fetch-depth: 0
dependabot[bot]fe858c52023-01-17 22:42:05 -050012 - uses: tj-actions/changed-files@v35
Mohammed Naser9a5ff202022-09-07 15:56:48 -040013 id: changed-files
14 with:
15 files: images/prometheus-ethtool-exporter/*
Mohammed Naser88cb2762023-01-18 03:28:21 +000016 - uses: docker/setup-qemu-action@v2
Mohammed Naser9a5ff202022-09-07 15:56:48 -040017 if: steps.changed-files.outputs.any_changed == 'true'
Mohammed Naser88cb2762023-01-18 03:28:21 +000018 - uses: docker/setup-buildx-action@v2
Mohammed Naser9a5ff202022-09-07 15:56:48 -040019 if: steps.changed-files.outputs.any_changed == 'true'
20 - run: echo PROJECT_REF=$(cat images/prometheus-ethtool-exporter/ref) >> $GITHUB_ENV
21 if: steps.changed-files.outputs.any_changed == 'true'
Mohammed Naser88cb2762023-01-18 03:28:21 +000022 - uses: docker/login-action@v2
Mohammed Naser9a5ff202022-09-07 15:56:48 -040023 if: steps.changed-files.outputs.any_changed == 'true'
24 with:
25 registry: quay.io
26 username: ${{ secrets.QUAY_USERNAME }}
27 password: ${{ secrets.QUAY_ROBOT_TOKEN }}
Mohammed Naser88cb2762023-01-18 03:28:21 +000028 - uses: docker/build-push-action@v3
Mohammed Naser9a5ff202022-09-07 15:56:48 -040029 if: steps.changed-files.outputs.any_changed == 'true'
30 with:
31 context: images/prometheus-ethtool-exporter
32 cache-from: type=gha,scope=prometheus-ethtool-exporter
33 cache-to: type=gha,mode=max,scope=prometheus-ethtool-exporter
34 platforms: linux/amd64,linux/arm64
35 push: true
36 build-args: |
37 PROJECT_REF=${{ env.PROJECT_REF }}
38 tags: |
39 quay.io/vexxhost/ethtool-exporter:${{ env.PROJECT_REF }}
Mohammed Naser25a07c42022-09-15 20:25:45 -040040
Mohammed Naser27292152022-09-19 19:26:24 -040041 pre-commit:
42 runs-on: ubuntu-latest
43 steps:
44 - name: Checkout project
Mohammed Naser88cb2762023-01-18 03:28:21 +000045 uses: actions/checkout@v3
Mohammed Naser27292152022-09-19 19:26:24 -040046
47 - name: Setup Python
Mohammed Naser88cb2762023-01-18 03:28:21 +000048 uses: actions/setup-python@v4
Mohammed Naser27292152022-09-19 19:26:24 -040049
50 - name: Setup pre-commit
Mohammed Naser88cb2762023-01-18 03:28:21 +000051 uses: pre-commit/action@v3
Mohammed Naser27292152022-09-19 19:26:24 -040052
Mohammed Naser25a07c42022-09-15 20:25:45 -040053 pytest:
54 runs-on: ubuntu-latest
55 strategy:
56 fail-fast: false
57 matrix:
Mohammed Naser182bcaf2022-09-18 10:43:36 -040058 type: [e2e, integration, unit]
Mohammed Naser25a07c42022-09-15 20:25:45 -040059 steps:
60 - name: Checkout project
Mohammed Naser88cb2762023-01-18 03:28:21 +000061 uses: actions/checkout@v3
Mohammed Naser25a07c42022-09-15 20:25:45 -040062
63 - name: Install Poetry
64 run: pipx install poetry
65
66 - name: Setup Python
Mohammed Naser88cb2762023-01-18 03:28:21 +000067 uses: actions/setup-python@v4
Mohammed Naser25a07c42022-09-15 20:25:45 -040068 with:
69 cache: poetry
70
Mohammed Naser8f61f0b2022-09-15 20:40:13 -040071 - name: Install dependencies
okozachenko1203fc31dcc2022-12-28 22:32:30 +110072 run: poetry install --no-interaction --all-extras
Mohammed Naser8f61f0b2022-09-15 20:40:13 -040073
Mohammed Naser25a07c42022-09-15 20:25:45 -040074 - name: Run test suite
75 run: poetry run pytest atmosphere/tests/${{ matrix.type }}
Mohammed Naserfe681de2022-10-12 15:42:25 +000076
77 molecule:
78 runs-on: ubuntu-latest
79 needs:
Mohammed Naserfe681de2022-10-12 15:42:25 +000080 - pytest
81 steps:
82 - name: Checkout project
Mohammed Naser88cb2762023-01-18 03:28:21 +000083 uses: actions/checkout@v3
Mohammed Naserfe681de2022-10-12 15:42:25 +000084
85 - name: Install Poetry
86 run: pipx install poetry
87
88 - name: Setup Python
Mohammed Naser88cb2762023-01-18 03:28:21 +000089 uses: actions/setup-python@v4
Mohammed Naserfe681de2022-10-12 15:42:25 +000090 with:
91 cache: poetry
92
93 - name: Install dependencies
okozachenko12034e1e0da2022-12-29 01:08:46 +110094 run: poetry install --no-interaction --all-extras
Mohammed Naserfe681de2022-10-12 15:42:25 +000095
96 # TODO(mnaser): Move this out to "cleanup" stage
97 - name: Set up Go
Mohammed Naser88cb2762023-01-18 03:28:21 +000098 uses: actions/setup-go@v3
Mohammed Naserfe681de2022-10-12 15:42:25 +000099 with:
100 go-version-file: go.mod
101 cache: true
102 - name: Clean-up stale stacks
103 run: go run ./cmd/atmosphere-ci molecule cleanup
104 env:
105 OS_AUTH_URL: https://auth.vexxhost.net/v3
106 OS_REGION_NAME: ca-ymq-1
107 OS_USER_DOMAIN_NAME: Default
108 OS_USERNAME: ${{ secrets.OS_USERNAME }}
109 OS_PASSWORD: ${{ secrets.OS_PASSWORD }}
110 OS_PROJECT_DOMAIN_NAME: Default
111 OS_PROJECT_NAME: ${{ secrets.OS_PROJECT_NAME }}
112
113 - name: Run Molecule
114 run: poetry run molecule test
115 timeout-minutes: 90
116 env:
117 ATMOSPHERE_STACK_NAME: "atmosphere-${{ github.run_id }}-${{ github.run_attempt }}"
118 OS_AUTH_URL: https://auth.vexxhost.net/v3
119 OS_REGION_NAME: ca-ymq-1
120 OS_USER_DOMAIN_NAME: Default
121 OS_USERNAME: ${{ secrets.OS_USERNAME }}
122 OS_PASSWORD: ${{ secrets.OS_PASSWORD }}
123 OS_PROJECT_DOMAIN_NAME: Default
124 OS_PROJECT_NAME: ${{ secrets.OS_PROJECT_NAME }}