Skip to content

Commit 68b00a2

Browse files
committed
Updating GitHub actions
1 parent 967e1f3 commit 68b00a2

File tree

3 files changed

+152
-67
lines changed

3 files changed

+152
-67
lines changed

.github/workflows/main.yml

Lines changed: 0 additions & 67 deletions
This file was deleted.

.github/workflows/publish.yml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License
14+
15+
name: PyPI releases
16+
on:
17+
workflow_dispatch:
18+
inputs:
19+
testpypi:
20+
type: boolean
21+
required: false
22+
default: false
23+
tag:
24+
type: string
25+
required: true
26+
jobs:
27+
build:
28+
name: Build distribution
29+
runs-on: ubuntu-latest
30+
# to build only on push to tags or on custom dispatched workflows
31+
if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/')
32+
steps:
33+
- uses: actions/checkout@v4
34+
with:
35+
persist-credentials: false
36+
- name: Set up Python
37+
uses: actions/setup-python@v5
38+
with:
39+
python-version: "3.x"
40+
- name: Install pypa/build
41+
run: pip --version
42+
run: pip install build
43+
- name: Clone pathwaysutils from tag
44+
if: github.event_name == 'worfklow_dispatch'
45+
run: git clone --branch=${{inputs.tag}} https://github.com/AI-Hypercomputer/pathways-utils.git
46+
- name: Enter directory
47+
if: github.event_name == 'worfklow_dispatch'
48+
run: cd pathways-utils
49+
- name: Build a binary wheel and a source tarball
50+
run: python3 -m build
51+
- name: Store the distribution packages
52+
uses: actions/upload-artifact@v4
53+
with:
54+
name: python-package-distributions
55+
path: dist/
56+
57+
publish-to-testpypi:
58+
if: ${{inputs.testpypi}} == true
59+
name: Publish Python distribution to TestPyPI
60+
uses: ./.github/actions/test.yml
61+
needs:
62+
- test
63+
- build
64+
runs-on: ubuntu-latest
65+
environment:
66+
name: testpypi
67+
url: https://test.pypi.org/p/pathwaysutils
68+
permissions:
69+
id-token: write
70+
steps:
71+
- name: Download all the dists
72+
uses: actions/download-artifact@v4
73+
with:
74+
name: python-package-distributions
75+
path: dist/
76+
- name: Publish distribution 📦 to TestPyPI
77+
uses: pypa/gh-action-pypi-publish@release/v1
78+
with:
79+
repository-url: https://test.pypi.org/legacy/
80+
verbose: true
81+
82+
publish-to-pypi:
83+
name: Publish Python distribution to PyPI
84+
uses: ./.github/actions/test.yml
85+
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
86+
needs:
87+
- test
88+
- build
89+
runs-on: ubuntu-latest
90+
environment:
91+
# We should configure trusted publishing as specified here:
92+
# https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/#configuring-trusted-publishing
93+
name: pypi
94+
url: https://pypi.org/p/pathwaysutils # Replace <package-name> with your PyPI project name
95+
permissions:
96+
id-token: write # IMPORTANT: mandatory for trusted publishing
97+
98+
steps:
99+
- name: Download all the dists
100+
uses: actions/download-artifact@v4
101+
with:
102+
name: python-package-distributions
103+
path: dist/
104+
- name: Publish distribution to PyPI
105+
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/test.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License
14+
#
15+
name: Unittests
16+
17+
# Allow to trigger the workflow manually (e.g. when deps changes)
18+
on: [push, workflow_dispatch]
19+
20+
jobs:
21+
unittest-job:
22+
name: Unittests
23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
python-version: ['3.10', '3.11', '3.12']
27+
runs-on: ubuntu-latest
28+
timeout-minutes: 30
29+
30+
concurrency:
31+
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.python-version }}
32+
cancel-in-progress: true
33+
34+
steps:
35+
- uses: actions/checkout@v4
36+
37+
# Install deps
38+
- uses: actions/setup-python@v5
39+
with:
40+
python-version: ${{ matrix.python-version }}
41+
- run: pip --version
42+
- run: pip install -e .
43+
- run: pip freeze
44+
45+
# Run tests
46+
- name: Run core tests
47+
run: python -m unittest discover --pattern "*_test.py" --start-directory "pathwaysutils/test"

0 commit comments

Comments
 (0)