Skip to content

Commit

Permalink
define the Python version used in production in two places only (#470)
Browse files Browse the repository at this point in the history
  • Loading branch information
lvaylet authored May 17, 2024
1 parent 47f5492 commit 3b44b86
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 15 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build-and-push-to-gcr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.9'
python-version: '${{ vars.PYTHON_VERSION }}'
architecture: 'x64'

- name: Check release version
Expand Down Expand Up @@ -44,7 +44,7 @@ jobs:
GCR_PROJECT_ID: ${{ secrets.GCR_PROJECT_ID }}
CLOUDBUILD_PROJECT_ID: ${{ secrets.CLOUDBUILD_PROJECT_ID }}
VERSION: ${{ steps.check-tag.outputs.match == 'true' && steps.check-tag.outputs.version || github.event.pull_request.head.sha || github.sha }}
# TODO: Pass the Python version too, for the `PYTHON_VERSION` build argument of the Dockerfile.
PYTHON_VERSION: ${{ vars.PYTHON_VERSION }}

- name: Build Docker container and publish on GCR [latest]
run: make cloud_build || true
Expand All @@ -53,4 +53,4 @@ jobs:
GCR_PROJECT_ID: ${{ secrets.GCR_PROJECT_ID }}
CLOUDBUILD_PROJECT_ID: ${{ secrets.CLOUDBUILD_PROJECT_ID }}
VERSION: latest
# TODO: Pass the Python version too, for the `PYTHON_VERSION` build argument of the Dockerfile.
PYTHON_VERSION: ${{ vars.PYTHON_VERSION }}
2 changes: 1 addition & 1 deletion .github/workflows/build-and-push-to-ghcr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
PYTHON_VERSION=3.9
PYTHON_VERSION=${{ vars.PYTHON_VERSION }}
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.9" # same as Dockerfile
python-version: '${{ vars.PYTHON_VERSION }}'

- name: Install dependencies
run: make install
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.9'
python-version: '${{ vars.PYTHON_VERSION }}'
architecture: 'x64'

- name: Run all tests
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

ARG PYTHON_VERSION
ARG PYTHON_VERSION=3.9

FROM python:${PYTHON_VERSION}-alpine

Expand Down
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,14 @@ docker_build:
DOCKER_BUILDKIT=1
docker build \
-t slo-generator:latest \
--build-arg PYTHON_VERSION=3.9 \
.

# Build Docker image with Cloud Build
cloud_build:
gcloud builds submit \
--config=cloudbuild.yaml \
--project=${CLOUDBUILD_PROJECT_ID} \
--substitutions=_GCR_PROJECT_ID=${GCR_PROJECT_ID},_VERSION=${VERSION}
--substitutions=_GCR_PROJECT_ID=${GCR_PROJECT_ID},_VERSION=${VERSION},_PYTHON_VERSION=${PYTHON_VERSION}

# Cloud Run
cloud_run:
Expand Down
10 changes: 4 additions & 6 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@ steps:
script: |
docker build \
-t gcr.io/$_GCR_PROJECT_ID/slo-generator:${_VERSION} \
--build-arg PYTHON_VERSION=3.9 \
--build-arg PYTHON_VERSION=${_PYTHON_VERSION} \
.
substitutions:
_VERSION: latest
options:
automapSubstitutions: true

images:
- gcr.io/$_GCR_PROJECT_ID/slo-generator:${_VERSION}

options:
automapSubstitutions: true

0 comments on commit 3b44b86

Please sign in to comment.