Skip to content

Commit b64d0ef

Browse files
authored
Add the workflow to test the latest Beam release (#17)
* added the workflow to test the latest Beam * add the version * fix the venv * fix the requests * fix the pip * add the packaging * change to test-latest-env
1 parent 4a88304 commit b64d0ef

File tree

3 files changed

+105
-0
lines changed

3 files changed

+105
-0
lines changed

.github/workflows/docker_test.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Copyright 2023 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: Build and push Docker image to GCP Artifact Registry with the latest Beam
16+
17+
on:
18+
workflow_dispatch:
19+
20+
jobs:
21+
build-and-push:
22+
runs-on: ubuntu-latest
23+
24+
steps:
25+
- name: Free Disk Space (Ubuntu)
26+
uses: jlumbroso/free-disk-space@main
27+
with:
28+
# this might remove tools that are actually needed,
29+
# if set to "true" but frees about 6 GB
30+
tool-cache: false
31+
32+
android: true
33+
dotnet: true
34+
haskell: true
35+
large-packages: false
36+
docker-images: true
37+
swap-storage: true
38+
- name: Checkout
39+
uses: actions/checkout@v3
40+
- id: "auth"
41+
name: Authenticate to Google Cloud
42+
uses: google-github-actions/[email protected]
43+
with:
44+
credentials_json: ${{ secrets.GOOGLE_CREDENTIALS }}
45+
token_format: access_token
46+
- name: Docker login
47+
uses: "docker/login-action@v1"
48+
with:
49+
registry: "us-docker.pkg.dev"
50+
username: "oauth2accesstoken"
51+
password: "${{ steps.auth.outputs.access_token }}"
52+
- name: Set up Python 3.8
53+
uses: actions/setup-python@v4
54+
with:
55+
python-version: "3.8"
56+
- name: Init env with the test Beam and docker URI
57+
run: |
58+
cp tests/sample.env.tf .env
59+
make init-venv
60+
./venv/bin/pip install requests packaging
61+
make test-latest-env
62+
sed -i '/CUSTOM_CONTAINER_IMAGE=/d' .env
63+
echo -e "\n" >> .env
64+
echo "CUSTOM_CONTAINER_IMAGE=us-docker.pkg.dev/apache-beam-testing/dataflow-ml-starter/tf_gpu:test-beam" >> .env
65+
echo '${{ steps.auth.outputs.access_token }}' | docker login -u oauth2accesstoken --password-stdin https://us-docker.pkg.dev
66+
make init
67+
- name: Build and push Docker image
68+
run: |
69+
make docker
70+
- name: Test Docker image
71+
run: |
72+
make run-df-gpu

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ help: ## Print this help
4848
@echo
4949
@$(PYTHON) -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)
5050

51+
test-latest-env: ## Replace the Beam vesion with the latest version (including release candidates)
52+
$(eval LATEST_VERSION=$(shell ./venv/bin/python3 scripts/get_beam_version.py))
53+
@echo $(LATEST_VERSION)
54+
@sed 's/BEAM_VERSION=.*/BEAM_VERSION=$(LATEST_VERSION)/g' .env > .env.new && mv .env.new .env
55+
5156
init-venv: ## Create virtual environment in venv folder
5257
@$(PYTHON) -m venv venv
5358

scripts/get_beam_version.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright 2023 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+
# third party libraries
16+
import requests
17+
from packaging.version import Version
18+
19+
20+
def beam_versions(package_name, limit_releases=10):
21+
url = f"https://pypi.org/pypi/{package_name}/json"
22+
data = requests.get(url).json()
23+
versions = list(data["releases"].keys())
24+
versions.sort(key=Version, reverse=True)
25+
return versions[:limit_releases]
26+
27+
28+
print("\n".join(beam_versions("apache-beam", 1)))

0 commit comments

Comments
 (0)