@@ -115,94 +115,176 @@ jobs:
115115 SHELLCHECK_OPTS : --exclude=SC2086 --exclude=SC2046 --exclude=SC2004 --exclude=SC2129
116116
117117
118- unit-tests :
119- strategy :
120- matrix :
121- python-version :
122- - " 3.9"
123- - " 3.10"
124- - " 3.11"
125- - " 3.12"
126- - " 3.13"
127- if : |
128- always() && !cancelled() &&
129- !contains(needs.*.result, 'failure') &&
130- !contains(needs.*.result, 'cancelled') &&
131- needs.files-changed.outputs.python == 'true'
132- needs : ["files-changed", "yaml-lint", "python-lint"]
133- runs-on : ubuntu-latest
134- timeout-minutes : 30
135- steps :
136- - name : " Check out repository code"
137- uses : " actions/checkout@v4"
138- - name : Set up Python ${{ matrix.python-version }}
139- uses : actions/setup-python@v5
140- with :
141- python-version : ${{ matrix.python-version }}
142- - name : " Setup environment"
143- run : |
144- pipx install poetry==1.8.5
145- poetry config virtualenvs.create true --local
146- pip install invoke toml codecov
147- - name : " Install Package"
148- run : " poetry install --all-extras"
149- - name : " Mypy Tests"
150- run : " poetry run mypy --show-error-codes infrahub_sdk/"
151- # - name: "Pylint Tests"
152- # run: "poetry run pylint infrahub_sdk/"
153- - name : " Unit Tests"
154- run : " poetry run pytest --cov infrahub_sdk tests/unit/"
155- - name : " Upload coverage to Codecov"
156- run : |
157- codecov --flags python-${{ matrix.python-version }}
158- env :
159- CODECOV_TOKEN : ${{ secrets.CODECOV_TOKEN }}
160-
161- # The pytest-cov plugin doesn't quite work with content that is
162- # auto-imported by our own infrahub pytest plugin, this workaround
163- # reports the missing lines
164- - name : " Report coverage for pytest-plugin"
165- if : matrix.python-version == '3.12'
166- run : |
167- source $(poetry env info --path)/bin/activate
168- coverage run --source=infrahub_sdk -m pytest tests/unit/pytest_plugin
169- coverage report -m
170- coverage xml
171- codecov --flags python-filler-${{ matrix.python-version }}
172- env :
173- CODECOV_TOKEN : ${{ secrets.CODECOV_TOKEN }}
118+ # unit-tests:
119+ # strategy:
120+ # matrix:
121+ # python-version:
122+ # - "3.9"
123+ # - "3.10"
124+ # - "3.11"
125+ # - "3.12"
126+ # - "3.13"
127+ # if: |
128+ # always() && !cancelled() &&
129+ # !contains(needs.*.result, 'failure') &&
130+ # !contains(needs.*.result, 'cancelled') &&
131+ # needs.files-changed.outputs.python == 'true'
132+ # needs: ["files-changed", "yaml-lint", "python-lint"]
133+ # runs-on: ubuntu-latest
134+ # timeout-minutes: 30
135+ # steps:
136+ # - name: "Check out repository code"
137+ # uses: "actions/checkout@v4"
138+ # - name: Set up Python ${{ matrix.python-version }}
139+ # uses: actions/setup-python@v5
140+ # with:
141+ # python-version: ${{ matrix.python-version }}
142+ # - name: "Setup environment"
143+ # run: |
144+ # pipx install poetry==1.8.5
145+ # poetry config virtualenvs.create true --local
146+ # pip install invoke toml codecov
147+ # - name: "Install Package"
148+ # run: "poetry install --all-extras"
149+ # - name: "Mypy Tests"
150+ # run: "poetry run mypy --show-error-codes infrahub_sdk/"
151+ # # - name: "Pylint Tests"
152+ # # run: "poetry run pylint infrahub_sdk/"
153+ # - name: "Unit Tests"
154+ # run: "poetry run pytest --cov infrahub_sdk tests/unit/"
155+ # - name: "Upload coverage to Codecov"
156+ # run: |
157+ # codecov --flags python-${{ matrix.python-version }}
158+ # env:
159+ # CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
160+ #
161+ # # The pytest-cov plugin doesn't quite work with content that is
162+ # # auto-imported by our own infrahub pytest plugin, this workaround
163+ # # reports the missing lines
164+ # - name: "Report coverage for pytest-plugin"
165+ # if: matrix.python-version == '3.12'
166+ # run: |
167+ # source $(poetry env info --path)/bin/activate
168+ # coverage run --source=infrahub_sdk -m pytest tests/unit/pytest_plugin
169+ # coverage report -m
170+ # coverage xml
171+ # codecov --flags python-filler-${{ matrix.python-version }}
172+ # env:
173+ # CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
174174
175175 # ------------------------------------------ Integration Tests ------------------------------------------
176- integration-tests :
176+ # integration-tests:
177+ # if: |
178+ # always() && !cancelled() &&
179+ # !contains(needs.*.result, 'failure') &&
180+ # !contains(needs.*.result, 'cancelled') &&
181+ # needs.files-changed.outputs.python == 'true'
182+ # needs: ["files-changed", "yaml-lint", "python-lint"]
183+ # runs-on:
184+ # group: "huge-runners"
185+ # timeout-minutes: 30
186+ # strategy:
187+ # matrix:
188+ # version: ["1.0.0", "1.1.0"]
189+ # steps:
190+ # - name: "Check out repository code"
191+ # uses: "actions/checkout@v4"
192+ # - name: Set up Python
193+ # uses: actions/setup-python@v5
194+ # with:
195+ # python-version: "3.12"
196+ # - name: "Set environment variables"
197+ # run: |
198+ # RUNNER_NAME=$(echo "${{ runner.name }}" | grep -o 'ghrunner[0-9]\+' | sed 's/ghrunner\([0-9]\+\)/ghrunner_\1/')
199+ # echo "PYTEST_DEBUG_TEMPROOT=/var/lib/github/${RUNNER_NAME}/_temp" >> $GITHUB_ENV
200+ # - name: "Setup environment"
201+ # run: |
202+ # pipx install poetry==1.8.5
203+ # poetry config virtualenvs.create true --local
204+ # pip install invoke toml codecov
205+ # - name: "Install Package"
206+ # run: "poetry install --all-extras"
207+ # - name: "Set environment variables for python_testcontainers"
208+ # run: |
209+ # echo INFRAHUB_TESTING_IMAGE_VER=${{ matrix.version }} >> $GITHUB_ENV
210+ # - name: "Integration Tests"
211+ # run: |
212+ # echo "Running tests for version: ${{ matrix.version }}"
213+ # poetry run pytest --cov infrahub_sdk tests/integration/
214+ # - name: "Upload coverage to Codecov"
215+ # run: |
216+ # codecov --flags integration-tests
217+ # env:
218+ # CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
219+ integration-tests-against-local-infrahub-build :
177220 if : |
178221 always() && !cancelled() &&
179222 !contains(needs.*.result, 'failure') &&
180223 !contains(needs.*.result, 'cancelled') &&
181- needs.files-changed.outputs.python == 'true'
224+ needs.files-changed.outputs.python == 'true' &&
225+ (github.base_ref == 'stable' || github.base_ref == 'develop')
182226 needs : ["files-changed", "yaml-lint", "python-lint"]
183227 runs-on :
184228 group : " huge-runners"
185229 timeout-minutes : 30
186230 steps :
187231 - name : " Check out repository code"
188232 uses : " actions/checkout@v4"
233+
234+ - name : " Extract target branch name"
235+ id : extract_branch
236+ run : echo "TARGET_BRANCH=${{ github.base_ref }}" >> $GITHUB_ENV
237+
238+ - name : " Checkout infrahub repository"
239+ uses : " actions/checkout@v4"
240+ with :
241+ repository : " opsmill/infrahub"
242+ path : " infrahub-server"
243+ ref : ${{ github.base_ref }}
244+ submodules : true
245+
189246 - name : Set up Python
190247 uses : actions/setup-python@v5
191248 with :
192249 python-version : " 3.12"
193- - name : " Set environment variables"
250+
251+ - name : " Setup git credentials prior dev.build"
252+ run : |
253+ cd infrahub-server
254+ git config --global user.name 'Infrahub'
255+ git config --global user.email '[email protected] ' 256+ git config --global --add safe.directory '*'
257+ git config --global credential.usehttppath true
258+ git config --global credential.helper /usr/local/bin/infrahub-git-credential
259+
260+ - name : " Set environment variables prior dev.build"
194261 run : |
262+ echo "INFRAHUB_BUILD_NAME=infrahub-${{ runner.name }}" >> $GITHUB_ENV
195263 RUNNER_NAME=$(echo "${{ runner.name }}" | grep -o 'ghrunner[0-9]\+' | sed 's/ghrunner\([0-9]\+\)/ghrunner_\1/')
196264 echo "PYTEST_DEBUG_TEMPROOT=/var/lib/github/${RUNNER_NAME}/_temp" >> $GITHUB_ENV
265+ echo "INFRAHUB_IMAGE_VER=local-${{ runner.name }}-${{ github.sha }}" >> $GITHUB_ENV
266+ echo "INFRAHUB_TESTING_IMAGE_TAG=local-${{ runner.name }}-${{ github.sha }}" >> $GITHUB_ENV
267+ echo "INFRAHUB_TESTING_DOCKER_IMAGE=opsmill/infrahub" >> $GITHUB_ENV
268+
269+ - name : " Build container"
270+ run : |
271+ cd infrahub-server
272+ inv dev.build
273+
197274 - name : " Setup environment"
198275 run : |
199276 pipx install poetry==1.8.5
200277 poetry config virtualenvs.create true --local
201278 pip install invoke toml codecov
279+
202280 - name : " Install Package"
203281 run : " poetry install --all-extras"
282+
204283 - name : " Integration Tests"
205- run : " poetry run pytest --cov infrahub_sdk tests/integration/"
284+ run : |
285+ echo "Running tests for version: $INFRAHUB_TESTING_IMAGE_TAG"
286+ poetry run pytest --cov infrahub_sdk tests/integration/
287+
206288 - name : " Upload coverage to Codecov"
207289 run : |
208290 codecov --flags integration-tests
0 commit comments