You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As noted by @maresb in this issue (pyscaffold/pyscaffoldext-markdown#11), both pyscaffoldext-markdown and pyscaffoldext-dsproject require git to be set up to run the tests.
I wanted to have some CI to run on github actions for a custom pyscaffold extension that I am developing, so to not rely on the developer to run the tests locally.
example
example of a .github/workflows/ci.yml file
(removed some redundant options for clarity and conciseness)
name: testson:
pull_request: # Run in every PRconcurrency:
group: >- ${{ github.workflow }}-${{ github.ref_type }}- ${{ github.event.pull_request.number || github.sha }}cancel-in-progress: truejobs:
prepare:
runs-on: ubuntu-latestoutputs:
wheel-distribution: ${{ steps.wheel-distribution.outputs.path }}steps:
- uses: actions/checkout@v3with: {fetch-depth: 0} # deep clone for setuptools-scm
- uses: actions/setup-python@v4id: setup-pythonwith: {python-version: "3.11"}
- name: Run static analysis and format checkersrun: pipx run pre-commit run --all-files --show-diff-on-failure
- name: Build package distribution filesrun: >- pipx run --python '${{ steps.setup-python.outputs.python-path }}' tox -e clean,build
- name: Record the path of wheel distributionid: wheel-distributionrun: echo "path=$(ls dist/*.whl)" >> $GITHUB_OUTPUT
- name: Store the distribution files for use in other stages# `tests` and `publish` will use the same pre-built distributions,# so we make sure to release the exact same package that was testeduses: actions/upload-artifact@v3with:
name: python-distribution-filespath: dist/retention-days: 1test:
needs: preparestrategy:
matrix:
python:
- "3.7"# oldest Python supported by PSF
- "3.11"# newest Python that is stableplatform:
- ubuntu-latest# - macos-latest# - windows-latestruns-on: ${{ matrix.platform }}steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4id: setup-pythonwith:
python-version: ${{ matrix.python }}
- name: Retrieve pre-built distribution filesuses: actions/download-artifact@v3with: {name: python-distribution-files, path: dist/}
- name: Run testsrun: >- pipx run --python '${{ steps.setup-python.outputs.python-path }}' tox --installpkg '${{ needs.prepare.outputs.wheel-distribution }}' -- -rFEx --durations 10 --color yes # pytest args
name: testson:
pull_request: # Run in every PRconcurrency:
group: >- ${{ github.workflow }}-${{ github.ref_type }}- ${{ github.event.pull_request.number || github.sha }}cancel-in-progress: truejobs:
prepare:
runs-on: ubuntu-latestoutputs:
wheel-distribution: ${{ steps.wheel-distribution.outputs.path }}steps:
- uses: actions/checkout@v3with: {fetch-depth: 0} # deep clone for setuptools-scm
- uses: actions/setup-python@v4id: setup-pythonwith: {python-version: "3.11"}
- name: Run static analysis and format checkersrun: pipx run pre-commit run --all-files --show-diff-on-failure
- name: Build package distribution filesrun: >- pipx run --python '${{ steps.setup-python.outputs.python-path }}' tox -e clean,build
- name: Record the path of wheel distributionid: wheel-distributionrun: echo "path=$(ls dist/*.whl)" >> $GITHUB_OUTPUT
- name: Store the distribution files for use in other stages# `tests` and `publish` will use the same pre-built distributions,# so we make sure to release the exact same package that was testeduses: actions/upload-artifact@v3with:
name: python-distribution-filespath: dist/retention-days: 1test:
needs: preparestrategy:
matrix:
python:
- "3.7"# oldest Python supported by PSF
- "3.11"# newest Python that is stableplatform:
- ubuntu-latest# - macos-latest# - windows-latestruns-on: ${{ matrix.platform }}steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4id: setup-pythonwith:
python-version: ${{ matrix.python }}
- uses: oleksiyrudenko/gha-git-credentials@v2-latestwith:
global: truename: 'Derp McDerpface'email: '[email protected]'actor: 'DerpMcDerpface'token: '${{ secrets.GITHUB_TOKEN }}'
- name: Retrieve pre-built distribution filesuses: actions/download-artifact@v3with: {name: python-distribution-files, path: dist/}
- name: Run testsrun: >- pipx run --python '${{ steps.setup-python.outputs.python-path }}' tox --installpkg '${{ needs.prepare.outputs.wheel-distribution }}' -- -rFEx --durations 10 --color yes # pytest args
conclusion
This ci.yml configuration allows for an automated run of the tests in CI.
If this seems like a good option for improvement, I'll make a PR with the suggested changes
The text was updated successfully, but these errors were encountered:
the problem
As noted by @maresb in this issue (pyscaffold/pyscaffoldext-markdown#11), both
pyscaffoldext-markdown
andpyscaffoldext-dsproject
require git to be set up to run the tests.Also related, this discussion on the pyscaffold repo: pyscaffold/pyscaffold#420
I wanted to have some CI to run on github actions for a custom pyscaffold extension that I am developing, so to not rely on the developer to run the tests locally.
example
example of a
.github/workflows/ci.yml
file(removed some redundant options for clarity and conciseness)
Running this will trigger the
GitNotConfigured
error, see pyscaffold/actions.py:222a possible solution
A possible solution is to run the
configure-git-credentials
github action with some dummy variables to trick the testing environment that git is set up.https://github.com/marketplace/actions/configure-git-credentials
example
conclusion
This
ci.yml
configuration allows for an automated run of the tests in CI.If this seems like a good option for improvement, I'll make a PR with the suggested changes
The text was updated successfully, but these errors were encountered: