Skip to content

Commit d68b18b

Browse files
ohriteerikamov
authored andcommitted
Update github actions
1 parent f06d86a commit d68b18b

File tree

5 files changed

+308
-100
lines changed

5 files changed

+308
-100
lines changed

.github/workflows/build-dask-image.yml

Lines changed: 40 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Build and push dask image
33
on:
44
push:
55
branches:
6-
- 'main'
6+
- main
77
paths:
88
- '.github/workflows/build-dask-image.yml'
99
- 'images/dask/**'
@@ -16,29 +16,52 @@ concurrency:
1616
group: ${{ github.workflow }}-${{ github.ref }}
1717
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
1818

19+
env:
20+
PYTHON_VERSION: '3.11'
21+
POETRY_VERSION: '2.0.1'
22+
1923
jobs:
20-
build_push:
21-
name: Package docker image
24+
docker:
25+
name: Push docker image
2226
runs-on: ubuntu-latest
27+
permissions:
28+
contents: read
29+
packages: write
30+
attestations: write
31+
id-token: write
2332
steps:
24-
- uses: actions/checkout@v2
25-
- uses: docker/login-action@v1
33+
- name: Checkout
34+
uses: actions/checkout@v4
35+
36+
- name: Set up Docker Buildx
37+
uses: docker/setup-buildx-action@v3
38+
39+
- name: Login to GitHub Repository
40+
uses: docker/login-action@v3
2641
with:
2742
registry: ghcr.io
2843
username: ${{ github.actor }}
2944
password: ${{ secrets.GITHUB_TOKEN }}
30-
- uses: actions/setup-python@v4
45+
46+
- name: Setup Python
47+
uses: actions/setup-python@v5
3148
with:
32-
python-version: '3.10'
33-
- run: curl -sSL https://install.python-poetry.org | python -
34-
# from https://forcepush.tech/python-package-ci-cd-with-git-hub-actions
35-
- name: Get image tag from version.txt
36-
run: |
37-
cd images/dask
38-
PROJECT_VERSION=$(cat version.txt)
39-
echo "PROJECT_VERSION=$PROJECT_VERSION" >> $GITHUB_ENV
40-
- uses: docker/build-push-action@v2
49+
python-version: ${{ env.PYTHON_VERSION }}
50+
51+
- name: Setup Poetry
52+
uses: abatilo/actions-poetry@v3
53+
with:
54+
poetry-version: ${{ env.POETRY_VERSION }}
55+
56+
- name: Get image tag from poetry
57+
working-directory: images/dask
58+
run: echo "PROJECT_VERSION=$(poetry version --short)" >> $GITHUB_ENV
59+
60+
- name: Build and Push
61+
uses: docker/build-push-action@v6
4162
with:
4263
context: images/dask
43-
push: ${{ github.ref == 'refs/heads/main' }}
44-
tags: ghcr.io/${{github.repository}}/dask:${{env.PROJECT_VERSION}}
64+
push: true
65+
tags: ghcr.io/${{ github.repository }}/jupyter-singleuser:${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && env.PROJECT_VERSION || 'development' }}
66+
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/jupyter-singleuser:${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && env.PROJECT_VERSION || 'development' }}
67+
cache-to: type=inline

.github/workflows/build-gtfs-rt-archiver-v3-image.yml

Lines changed: 78 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Build and push gtfs-rt-archiver-v3 image
33
on:
44
push:
55
branches:
6-
- 'main'
6+
- main
77
paths:
88
- '.github/workflows/build-gtfs-rt-archiver-v3-image.yml'
99
- 'services/gtfs-rt-archiver-v3/**'
@@ -16,47 +16,95 @@ concurrency:
1616
group: ${{ github.workflow }}-${{ github.ref }}
1717
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
1818

19+
env:
20+
PYTHON_VERSION: '3.11'
21+
POETRY_VERSION: '2.0.1'
22+
1923
jobs:
20-
check:
21-
name: Run static checkers
24+
lint:
25+
name: Lint
2226
runs-on: ubuntu-latest
23-
env:
24-
CALITP_BUCKET__GTFS_RT_PARSED: gs://some-test-bucket
25-
CALITP_BUCKET__GTFS_RT_VALIDATION: gs://some-test-bucket
26-
GTFS_RT_VALIDATOR_VERSION: v0.0.0
2727
steps:
28-
- uses: actions/checkout@v2
29-
- uses: actions/setup-python@v4
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
31+
- name: Setup Graphviz
32+
uses: ts-graphviz/setup-graphviz@v2
33+
34+
- name: Setup Python
35+
uses: actions/setup-python@v5
36+
with:
37+
python-version: ${{ env.PYTHON_VERSION }}
38+
39+
- name: Cache poetry
40+
uses: actions/cache@v3
41+
with:
42+
path: ~/.cache/pypoetry
43+
key: poetry-cache-${{ runner.os }}-python-${{ env.PYTHON_VERSION }}-poetry-${{ env.POETRY_VERSION }}
44+
45+
- name: Setup Poetry
46+
uses: abatilo/actions-poetry@v3
47+
with:
48+
poetry-version: ${{ env.POETRY_VERSION }}
49+
50+
- name: Cache python packages
51+
uses: actions/cache@v3
3052
with:
31-
python-version: '3.9'
32-
- run: curl -sSL https://install.python-poetry.org | python -
33-
- run: cd services/gtfs-rt-archiver-v3 && poetry install && poetry run mypy .
53+
path: ~/.local
54+
key: python-cache-${{ runner.os }}-python-${{ env.PYTHON_VERSION }}-lock-${{ hashFiles('poetry.lock') }}-${{ hashFiles('.github/workflows/*.yml') }}
3455

35-
build_push:
36-
name: Package docker image
56+
- name: Install dependencies
57+
working-directory: services/gtfs-rt-archiver-v3
58+
run: poetry install
59+
60+
- name: Run mypy
61+
working-directory: services/gtfs-rt-archiver-v3
62+
run: poetry run mypy .
63+
64+
docker:
65+
name: Push docker image
3766
runs-on: ubuntu-latest
38-
needs: [check]
67+
permissions:
68+
contents: read
69+
packages: write
70+
attestations: write
71+
id-token: write
3972
steps:
40-
- uses: actions/checkout@v2
41-
- uses: docker/login-action@v1
73+
- name: Checkout
74+
uses: actions/checkout@v4
75+
76+
- name: Set up Docker Buildx
77+
uses: docker/setup-buildx-action@v3
78+
79+
- name: Login to GitHub Repository
80+
uses: docker/login-action@v3
4281
with:
4382
registry: ghcr.io
4483
username: ${{ github.actor }}
4584
password: ${{ secrets.GITHUB_TOKEN }}
46-
- uses: actions/setup-python@v4
85+
86+
- name: Setup Python
87+
uses: actions/setup-python@v5
4788
with:
48-
python-version: '3.10'
49-
- run: curl -sSL https://install.python-poetry.org | python -
50-
# from https://forcepush.tech/python-package-ci-cd-with-git-hub-actions
51-
- name: Get image tag from pyproject.toml and commit SHA
52-
run: |
53-
cd services/gtfs-rt-archiver-v3
54-
PROJECT_VERSION=$(poetry version --short)
55-
echo "PROJECT_VERSION=$PROJECT_VERSION" >> $GITHUB_ENV
89+
python-version: ${{ env.PYTHON_VERSION }}
90+
91+
- name: Setup Poetry
92+
uses: abatilo/actions-poetry@v3
93+
with:
94+
poetry-version: ${{ env.POETRY_VERSION }}
95+
96+
- name: Get image tag from poetry
97+
working-directory: services/gtfs-rt-archiver-v3
98+
run: echo "PROJECT_VERSION=$(poetry version --short)" >> $GITHUB_ENV
99+
100+
- name: Get short GitHub SHA
101+
run: echo "GITHUB_SHA_SHORT=${GITHUB_SHA:0:6}" >> $GITHUB_ENV
56102

57-
echo "GITHUB_SHA_SHORT=${GITHUB_SHA:0:6}" >> $GITHUB_ENV
58-
- uses: docker/build-push-action@v2
103+
- name: Build and Push
104+
uses: docker/build-push-action@v6
59105
with:
60106
context: services/gtfs-rt-archiver-v3
61-
push: ${{ github.ref == 'refs/heads/main' }}
62-
tags: ghcr.io/${{github.repository}}/gtfs-rt-archiver-v3:${{env.PROJECT_VERSION}}-${{env.GITHUB_SHA_SHORT}}
107+
push: true
108+
tags: ghcr.io/${{ github.repository }}/gtfs-rt-parser-v2:${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && 'latest' || 'development' }}
109+
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/gtfs-rt-parser-v2:${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && env.PROJECT_VERSION || 'development' }}${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && '-' || '' }}${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && env.GITHUB_SHA_SHORT || '' }}
110+
cache-to: type=inline

.github/workflows/build-gtfs-rt-parser-v2-image.yml

Lines changed: 52 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Build and push gtfs-rt-parser-v2 image
33
on:
44
push:
55
branches:
6-
- 'main'
6+
- main
77
paths:
88
- '.github/workflows/build-gtfs-rt-parser-v2-image.yml'
99
- 'jobs/gtfs-rt-parser-v2/**'
@@ -17,23 +17,26 @@ concurrency:
1717
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
1818

1919
env:
20-
PYTHON_VERSION: '3.9'
20+
PYTHON_VERSION: '3.11'
2121
POETRY_VERSION: '2.0.1'
2222

2323
jobs:
24-
check:
25-
name: Run lint and Test
24+
lint:
25+
name: Lint
2626
runs-on: ubuntu-latest
2727
steps:
2828
- name: Checkout
2929
uses: actions/checkout@v4
3030

31+
- name: Setup Graphviz
32+
uses: ts-graphviz/setup-graphviz@v2
33+
3134
- name: Setup Python
3235
uses: actions/setup-python@v5
3336
with:
3437
python-version: ${{ env.PYTHON_VERSION }}
3538

36-
- name: Cache Poetry
39+
- name: Cache poetry
3740
uses: actions/cache@v3
3841
with:
3942
path: ~/.cache/pypoetry
@@ -44,28 +47,63 @@ jobs:
4447
with:
4548
poetry-version: ${{ env.POETRY_VERSION }}
4649

47-
- name: Cache Python packages
50+
- name: Cache python packages
4851
uses: actions/cache@v3
4952
with:
5053
path: ~/.local
51-
key: python-cache-${{ runner.os }}-python-${{ env.PYTHON_VERSION }}-lock-${{ hashFiles('warehouse/poetry.lock') }}-${{ hashFiles('.github/workflows/*.yml') }}
54+
key: python-cache-${{ runner.os }}-python-${{ env.PYTHON_VERSION }}-lock-${{ hashFiles('poetry.lock') }}-${{ hashFiles('.github/workflows/*.yml') }}
5255

5356
- name: Install dependencies
5457
working-directory: jobs/gtfs-rt-parser-v2
5558
run: poetry install
5659

57-
- name: Run linter
60+
- name: Run mypy
5861
working-directory: jobs/gtfs-rt-parser-v2
5962
run: poetry run mypy .
6063

64+
test:
65+
name: Test
66+
runs-on: ubuntu-latest
67+
steps:
68+
- name: Checkout
69+
uses: actions/checkout@v4
70+
71+
- name: Setup Graphviz
72+
uses: ts-graphviz/setup-graphviz@v2
73+
74+
- name: Setup Python
75+
uses: actions/setup-python@v5
76+
with:
77+
python-version: ${{ env.PYTHON_VERSION }}
78+
79+
- name: Cache poetry
80+
uses: actions/cache@v3
81+
with:
82+
path: ~/.cache/pypoetry
83+
key: poetry-cache-${{ runner.os }}-python-${{ env.PYTHON_VERSION }}-poetry-${{ env.POETRY_VERSION }}
84+
85+
- name: Setup Poetry
86+
uses: abatilo/actions-poetry@v3
87+
with:
88+
poetry-version: ${{ env.POETRY_VERSION }}
89+
90+
- name: Cache python packages
91+
uses: actions/cache@v3
92+
with:
93+
path: ~/.local
94+
key: python-cache-${{ runner.os }}-python-${{ env.PYTHON_VERSION }}-lock-${{ hashFiles('poetry.lock') }}-${{ hashFiles('.github/workflows/*.yml') }}
95+
96+
- name: Install dependencies
97+
working-directory: jobs/gtfs-rt-parser-v2
98+
run: poetry install
99+
61100
- name: Run pytest
62101
working-directory: jobs/gtfs-rt-parser-v2
63102
run: poetry run pytest
64103

65-
build_push:
66-
name: Package docker image
104+
docker:
105+
name: Push docker image
67106
runs-on: ubuntu-latest
68-
needs: [check]
69107
permissions:
70108
contents: read
71109
packages: write
@@ -75,6 +113,9 @@ jobs:
75113
- name: Checkout
76114
uses: actions/checkout@v4
77115

116+
- name: Set up Docker Buildx
117+
uses: docker/setup-buildx-action@v3
118+
78119
- name: Login to GitHub Repository
79120
uses: docker/login-action@v3
80121
with:

0 commit comments

Comments
 (0)