Skip to content

Commit 5c2f5f6

Browse files
committed
multiple python versions
1 parent 617f113 commit 5c2f5f6

File tree

5 files changed

+51
-41
lines changed

5 files changed

+51
-41
lines changed

.github/testing/bun.lockb

-32 Bytes
Binary file not shown.

.github/testing/src/config/python.ts

+25-26
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,29 @@
1414

1515
import * as path from 'path';
1616
import * as subprocess from '../subprocess';
17-
import { Config } from '../config';
17+
import {Config} from '../config';
1818

19-
export const python = new Config({
20-
match: ['**'],
21-
ignore: ['**/README.md', 'pytest.ini'],
22-
packageFile: [
23-
'noxfile_config.py',
24-
'requirements.txt',
25-
'pyproject.toml',
26-
'setup.py',
27-
'setup.cfg',
28-
],
29-
testAll: args => {
30-
const noxfile = path.join(args.root, 'noxfile-template.py');
31-
subprocess.run('cp', [noxfile, 'noxfile.py']);
32-
subprocess.run('nox', ['-s', 'py-3.11']);
33-
// subprocess.run('pip', ['install', '-r', 'requirements.txt', '-r', 'requirements-test.txt', '--only-binary', ':all'])
34-
// subprocess.run('pytest', ['-s'])
35-
},
36-
testSome: args => {
37-
subprocess.run('cp', [
38-
path.join(args.root, 'noxfile-template.py'),
39-
'noxfile.py',
40-
]);
41-
throw `TODO: config/python.ts testSome ${JSON.stringify(args)}`;
42-
},
43-
});
19+
export const python = (version = '3.11') =>
20+
new Config({
21+
match: ['**'],
22+
ignore: ['**/README.md', 'pytest.ini'],
23+
packageFile: [
24+
'noxfile_config.py',
25+
'requirements.txt',
26+
'pyproject.toml',
27+
'setup.py',
28+
'setup.cfg',
29+
],
30+
testAll: args => {
31+
const noxfile = path.join(args.root, 'noxfile-template.py');
32+
subprocess.run('cp', [noxfile, 'noxfile.py']);
33+
subprocess.run('nox', ['-s', `py-${version}`]);
34+
},
35+
testSome: args => {
36+
subprocess.run('cp', [
37+
path.join(args.root, 'noxfile-template.py'),
38+
'noxfile.py',
39+
]);
40+
throw `TODO: config/python.ts testSome ${JSON.stringify(args)}`;
41+
},
42+
});

.github/testing/src/main.ts

+11-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,17 @@ import { Affected } from './affected';
1919

2020
function getConfig(lang: string): Config {
2121
switch (lang) {
22+
case 'python3.8':
23+
return python('3.8');
24+
case 'python3.9':
25+
return python('3.9');
26+
case 'python3.10':
27+
return python('3.10');
28+
case 'python3.11':
29+
return python('3.11');
30+
case 'python3.12':
2231
case 'python':
23-
return python;
32+
return python('3.12');
2433
}
2534
throw `unsupported language: ${lang}`;
2635
}
@@ -37,7 +46,7 @@ function main(command: string) {
3746
}
3847
case 'tests': {
3948
const config = getConfig(process.argv[3]);
40-
const affected: Affected = JSON.parse(process.env[process.argv[4]] || "");
49+
const affected: Affected = JSON.parse(process.env[process.argv[4]] || '');
4150
config.test(affected);
4251
return;
4352
}

.github/testing/src/subprocess.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
import { spawnSync } from 'child_process';
15+
import {spawnSync} from 'child_process';
1616

1717
export function run(cmd: string, args: string[]) {
18-
const p = spawnSync(cmd, args, { stdio: 'inherit' });
18+
const p = spawnSync(cmd, args, {stdio: 'inherit'});
1919
if (p.status !== 0) {
2020
process.exitCode = p.status || undefined;
2121
}

.github/workflows/test.yaml

+13-11
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ on:
2020
pull_request:
2121
workflow_dispatch: # Manual runs
2222

23+
env:
24+
PROJECT: jss-22p1-test
25+
WORKLOAD_IDENTITY_PROVIDER: projects/886556137211/locations/global/workloadIdentityPools/github-actions/providers/github-actions-python
26+
2327
jobs:
2428
affected:
2529
runs-on: ubuntu-latest
@@ -40,19 +44,17 @@ jobs:
4044
echo "$AFFECTED_PYTHON"
4145
echo "affected=$AFFECTED_PYTHON" >> "$GITHUB_OUTPUT"
4246
43-
Python:
47+
python-311:
48+
name: Python ${{matrix.python-version}}
4449
needs: affected
4550
runs-on: ubuntu-latest
4651
strategy:
4752
matrix:
53+
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
4854
affected: ${{fromJson(needs.affected.outputs.python)}}
49-
# Needed to generate the identity token for google-github-actions/auth.
50-
# https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-google-cloud-platform
5155
permissions:
52-
id-token: write # This is required for requesting the JWT
53-
contents: read # This is required for actions/checkout
54-
env:
55-
GOOGLE_CLOUD_PROJECT: jss-22p1-test
56+
id-token: write
57+
contents: read
5658
defaults:
5759
run:
5860
working-directory: .github/testing
@@ -61,13 +63,13 @@ jobs:
6163
- uses: oven-sh/setup-bun@v2
6264
- uses: actions/setup-python@v5
6365
with:
64-
python-version: '3.11'
66+
python-version: ${{matrix.python-version}}
6567
- uses: 'google-github-actions/auth@v2'
6668
with:
67-
project_id: jss-22p1-test
68-
workload_identity_provider: projects/886556137211/locations/global/workloadIdentityPools/github-actions/providers/github-actions-python
69+
project_id: $PROJECT
70+
workload_identity_provider: $WORKLOAD_IDENTITY_PROVIDER
6971
- run: pip install nox
7072
- run: bun install
71-
- run: bun run tests python AFFECTED
73+
- run: bun run tests python${{matrix.python-version}} AFFECTED
7274
env:
7375
AFFECTED: ${{toJson(matrix.affected)}}

0 commit comments

Comments
 (0)