@@ -115,65 +115,108 @@ 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') &&
@@ -186,23 +229,61 @@ jobs:
186229 steps :
187230 - name : " Check out repository code"
188231 uses : " actions/checkout@v4"
232+
233+ - name : " Extract target branch name"
234+ id : extract_branch
235+ run : echo "TARGET_BRANCH=\${{ github.base_ref }}" >> $GITHUB_ENV
236+
237+ - name : " Checkout infrahub repository"
238+ uses : " actions/checkout@v4"
239+ with :
240+ repository : " opsmill/infrahub"
241+ path : " infrahub-server"
242+ ref : $TARGET_BRANCH
243+ submodules : true
244+
189245 - name : Set up Python
190246 uses : actions/setup-python@v5
191247 with :
192248 python-version : " 3.12"
193- - name : " Set environment variables"
249+
250+ - name : " Setup git credentials prior dev.build"
251+ run : |
252+ cd infrahub-server
253+ git config --global user.name 'Infrahub'
254+ git config --global user.email '[email protected] ' 255+ git config --global --add safe.directory '*'
256+ git config --global credential.usehttppath true
257+ git config --global credential.helper /usr/local/bin/infrahub-git-credential
258+
259+ - name : " Set environment variables prior dev.build"
194260 run : |
261+ echo "INFRAHUB_BUILD_NAME=infrahub-${{ runner.name }}" >> $GITHUB_ENV
195262 RUNNER_NAME=$(echo "${{ runner.name }}" | grep -o 'ghrunner[0-9]\+' | sed 's/ghrunner\([0-9]\+\)/ghrunner_\1/')
196263 echo "PYTEST_DEBUG_TEMPROOT=/var/lib/github/${RUNNER_NAME}/_temp" >> $GITHUB_ENV
264+ echo "INFRAHUB_IMAGE_VER=local-${{ runner.name }}-${{ github.sha }}" >> $GITHUB_ENV
265+ echo "INFRAHUB_TESTING_IMAGE_TAG=local-${{ runner.name }}-${{ github.sha }}" >> $GITHUB_ENV
266+ echo "INFRAHUB_TESTING_DOCKER_IMAGE=opsmill/infrahub" >> $GITHUB_ENV
267+
268+ - name : " Build container"
269+ run : |
270+ cd infrahub-server
271+ inv dev.build
272+
197273 - name : " Setup environment"
198274 run : |
199275 pipx install poetry==1.8.5
200276 poetry config virtualenvs.create true --local
201277 pip install invoke toml codecov
278+
202279 - name : " Install Package"
203280 run : " poetry install --all-extras"
281+
204282 - name : " Integration Tests"
205- run : " poetry run pytest --cov infrahub_sdk tests/integration/"
283+ run : |
284+ echo "Running tests for version: $INFRAHUB_TESTING_IMAGE_TAG"
285+ poetry run pytest --cov infrahub_sdk tests/integration/
286+
206287 - name : " Upload coverage to Codecov"
207288 run : |
208289 codecov --flags integration-tests
0 commit comments