File tree Expand file tree Collapse file tree 3 files changed +35
-0
lines changed
Expand file tree Collapse file tree 3 files changed +35
-0
lines changed Original file line number Diff line number Diff line change 5353 python_version : ${{ env.python_version }}
5454 path_prefix : " test-python-project"
5555 tests_path : " tests"
56+ github_token : ${{ secrets.GITHUB_TOKEN }}
5657
5758 # Perform Python project failing tests
5859 - name : " Run action: ${{ github.repository }} [Test Failure]"
6465 # Test permit failure using action input
6566 tests_path : " tests_fail"
6667 permit_fail : true
68+ github_token : ${{ secrets.GITHUB_TOKEN }}
6769
6870 # Perform Python project failing tests
6971 - name : " Run action: ${{ github.repository }} [Test Failure]"
7678 report_artefact : false
7779 # Test permit failure using action input
7880 tests_path : " tests_fail"
81+ github_token : ${{ secrets.GITHUB_TOKEN }}
7982
8083 - name : " Validate previous step failure"
8184 if : steps.tests-fail.outcome == 'success'
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ The example below demonstrates an implementation as a matrix job:
3838 with :
3939 python_version : ${{ matrix.python-version }}
4040 report_artefact : true
41+ github_token : ${{ secrets.GITHUB_TOKEN }}
4142` ` `
4243
4344Note: build your project before invoking tests (not shown above)
@@ -57,10 +58,29 @@ Note: build your project before invoking tests (not shown above)
5758| tests_path | False | test/tests | Path relative to the project folder containing tests |
5859| tox_tests | False | False | Uses tox to perform Python tests (requires tox.ini) |
5960| tox_envs | False | "lint tests" | Space separated list of tox environment names to run |
61+ | github_token | False | | GitHub token for API access during tests |
6062
6163<!-- markdownlint-enable MD013 -->
6264
6365## Coverage Reports
6466
6567The embedded pytest behaviour will create HTML coverage reports as ZIP file
6668bundles. Set REPORT_ARTEFACT true to also upload them to GitHub as artefacts.
69+
70+ ## GitHub Token Support
71+
72+ The action accepts an optional ` github_token` input parameter that makes the
73+ GitHub token available to your tests as the `GITHUB_TOKEN` environment variable.
74+ This is useful for tests that need to interact with GitHub APIs or access
75+ private repositories without encountering rate limits.
76+
77+ # ## Example with GitHub Token
78+
79+ ` ` ` yaml
80+ - name: "Test Python project with GitHub API access"
81+ uses: lfreleng-actions/python-test-action@main
82+ with:
83+ python_version: "3.12"
84+ github_token: ${{ secrets.GITHUB_TOKEN }}
85+ report_artefact: true
86+ ` ` `
Original file line number Diff line number Diff line change @@ -42,12 +42,18 @@ inputs:
4242 description : ' Space separated list of tox environments to run'
4343 required : false
4444 # type: string
45+ github_token :
46+ description : ' GitHub token for API access during tests'
47+ required : false
48+ # type: string
4549
4650runs :
4751 using : ' composite'
4852 steps :
4953 - name : ' Setup action/environment'
5054 shell : bash
55+ env :
56+ GITHUB_TOKEN : ${{ inputs.github_token }}
5157 run : |
5258 # Setup action/environment
5359 if [ -z "${{ inputs.python_version }}" ]; then
@@ -170,6 +176,8 @@ runs:
170176 - name : ' Performing tests [tox]'
171177 if : steps.tox-config.outputs.type == 'file' && inputs.tox_tests == 'true'
172178 shell : bash
179+ env :
180+ GITHUB_TOKEN : ${{ inputs.github_token }}
173181 run : |
174182 # Performing tests [tox]
175183 echo 'Installing: tox ⬇️'
@@ -194,6 +202,8 @@ runs:
194202 - name : ' Install project and test/dev dependencies [pytest]'
195203 if : inputs.tox_tests != 'true'
196204 shell : bash
205+ env :
206+ GITHUB_TOKEN : ${{ inputs.github_token }}
197207 run : |
198208 # Install project and test/dev dependencies
199209
@@ -226,6 +236,8 @@ runs:
226236 - name : ' Run tests and coverage report [pytest]'
227237 if : inputs.tox_tests != 'true'
228238 shell : bash
239+ env :
240+ GITHUB_TOKEN : ${{ inputs.github_token }}
229241 run : |
230242 # Tests and coverage report [pytest]
231243
You can’t perform that action at this time.
0 commit comments