Skip to content

Commit 0ffa976

Browse files
authored
ci: Add actions smoke test (#9)
* ci: Add actions smoke test * ci: Adjust include paths of workflow * ci: Adjust bake config file * ci: Add config-file input to shard action * ci: Pass config file path * fix: Remove superfluous quote * chore: Add suffix
1 parent 013e648 commit 0ffa976

File tree

8 files changed

+163
-21
lines changed

8 files changed

+163
-21
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
---
2+
name: actions-smoke-test
3+
4+
on:
5+
workflow_dispatch:
6+
pull_request:
7+
paths:
8+
- .github/workflows/pr_actions-smoke-test.yml
9+
- build-container-image/action.yml
10+
- build-product-image/action.yml
11+
- publish-image/action.yml
12+
- publish-index-manifest/action.yml
13+
- shard/action.yml
14+
- smoke/*
15+
16+
jobs:
17+
generate_matrix:
18+
name: Generate Version List
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
22+
- id: shard
23+
uses: ./shard
24+
with:
25+
product-name: smoke
26+
config-file: smoke/conf.py
27+
outputs:
28+
versions: ${{ steps.shard.outputs.versions }}
29+
30+
build:
31+
name: Build/Publish Smoke Test (${{ matrix.versions }}-${{ matrix.runner.arch }}) Image
32+
needs: [generate_matrix]
33+
permissions:
34+
id-token: write
35+
runs-on: ${{ matrix.runner.name }}
36+
strategy:
37+
matrix:
38+
runner:
39+
- {name: "ubuntu-latest", arch: "amd64"}
40+
- {name: "ubicloud-standard-8-arm", arch: "arm64"}
41+
versions: ${{ fromJson(needs.generate_matrix.outputs.versions) }}
42+
steps:
43+
- name: Checkout Repository
44+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
45+
46+
- name: Build Product Container Image
47+
id: build
48+
uses: ./build-product-image
49+
with:
50+
product-name: smoke
51+
product-version: ${{ matrix.versions }}
52+
build-cache-password: ${{ secrets.BUILD_CACHE_NEXUS_PASSWORD }}
53+
bake-config-file: smoke/conf.py
54+
55+
- name: Publish Container Image on oci.stackable.tech
56+
uses: ./publish-image
57+
with:
58+
image-registry-uri: oci.stackable.tech
59+
image-registry-username: robot$stackable+github-action-build
60+
image-registry-password: ${{ secrets.HARBOR_ROBOT_STACKABLE_GITHUB_ACTION_BUILD_SECRET }}
61+
image-repository: stackable/smoke
62+
image-manifest-tag: ${{ steps.build.outputs.image-manifest-tag }}
63+
source-image-uri: localhost/smoke:${{ steps.build.outputs.image-manifest-tag }}
64+
65+
publish_manifests:
66+
name: Build/Publish ${{ matrix.versions }} Index Manifest
67+
needs: [generate_matrix, build]
68+
permissions:
69+
id-token: write
70+
runs-on: ubuntu-latest
71+
strategy:
72+
matrix:
73+
versions: ${{ fromJson(needs.generate_matrix.outputs.versions) }}
74+
steps:
75+
- name: Checkout Repository
76+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
77+
78+
- name: Publish and Sign Image Index Manifest to oci.stackable.tech
79+
uses: ./publish-index-manifest
80+
with:
81+
image-registry-uri: oci.stackable.tech
82+
image-registry-username: robot$stackable+github-action-build
83+
image-registry-password: ${{ secrets.HARBOR_ROBOT_STACKABLE_GITHUB_ACTION_BUILD_SECRET }}
84+
image-repository: stackable/smoke
85+
image-index-manifest-tag: ${{ matrix.versions }}-stackable0.0.0-dev

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__pycache__

.scripts/shard.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import importlib.util
2+
import sys
3+
import os
4+
5+
sys.path.append(str(os.getcwd()))
6+
7+
def import_from_path(module_name, file_path):
8+
spec = importlib.util.spec_from_file_location(module_name, file_path)
9+
module = importlib.util.module_from_spec(spec)
10+
sys.modules[module_name] = module
11+
spec.loader.exec_module(module)
12+
return module
13+
14+
# import smoke.conf as conf
15+
file = os.environ['CONFIG_FILE'] if os.environ['CONFIG_FILE'] else 'conf'
16+
conf = import_from_path('conf', file)
17+
18+
product=os.environ['PRODUCT_NAME']
19+
print(f"Generating version list for {product}")
20+
21+
# get the product config
22+
product_conf = list(filter(lambda x: x["name"] == product, conf.products))[0]
23+
# list the versions, eg: [1.0, 1.1, 2.0]
24+
versions = [v["product"] for k,v in enumerate(product_conf["versions"])]
25+
output_versions = f"VERSIONS={versions}\n"
26+
27+
github_outputs_file = os.environ['GITHUB_OUTPUT']
28+
f = open(github_outputs_file, "w")
29+
print(f"Writing to $GITHUB_OUTPUT: {output_versions}")
30+
f.write(output_versions)
31+
f.close()

build-product-image/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ runs:
8686
--export-tags-file bake-target-tags \
8787
--configuration "$BAKE_CONFIG_FILE" \
8888
--cache
89-
echo "::endgroup::""
89+
echo "::endgroup::"
9090
9191
- name: Re-tag Image (Temporary)
9292
shell: bash

shard/action.yml

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ inputs:
55
product-name:
66
description: The name of the product to build via bake (directory name)
77
required: true
8+
config-file:
9+
description: Path the the config file used to generate the shard indices
10+
default: ./conf.py
811
outputs:
912
versions:
1013
description: A list of product versions
@@ -15,32 +18,25 @@ runs:
1518
- uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
1619
with:
1720
python-version: '3.12'
21+
22+
- name: Extract Action Path
23+
shell: bash
24+
env:
25+
GITHUB_ACTION_PATH: ${{ github.action_path }}
26+
run: |
27+
set -euo pipefail
28+
echo "GITHUB_ACTION_PATH=$GITHUB_ACTION_PATH" | tee -a "$GITHUB_ENV"
29+
1830
- name: Generate Shards
1931
id: generate_shards
20-
shell: python
32+
shell: bash
2133
env:
2234
PRODUCT_NAME: ${{ inputs.product-name }}
35+
CONFIG_FILE: ${{ inputs.config-file }}
2336
run: |
24-
# Need to get the list of versions for the product
25-
import sys
26-
import os
27-
sys.path.append(str(os.getcwd()))
28-
import conf
29-
30-
product=os.environ['PRODUCT_NAME']
31-
print(f"Generating version list for {product}")
32-
33-
# get the product config
34-
product_conf = list(filter(lambda x: x["name"] == product, conf.products))[0]
35-
# list the versions, eg: [1.0, 1.1, 2.0]
36-
versions = [v["product"] for k,v in enumerate(product_conf["versions"])]
37-
output_versions = f"VERSIONS={versions}\n"
37+
set -euo pipefail
38+
python "$GITHUB_ACTION_PATH/../.scripts/shard.py"
3839
39-
github_outputs_file = os.environ['GITHUB_OUTPUT']
40-
f = open(github_outputs_file, "w")
41-
print(f"Writing to $GITHUB_OUTPUT: {output_versions}")
42-
f.write(output_versions)
43-
f.close()
4440
- name: Print Shards
4541
shell: bash
4642
run: |

smoke/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM alpine
2+
3+
RUN echo "I'm a smoke test coming from https://github.com/stackabletech/actions"

smoke/conf.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import smoke.versions as smoke
2+
3+
products = [
4+
{
5+
"name": "smoke",
6+
"versions": smoke.versions,
7+
},
8+
]
9+
10+
cache = [
11+
{
12+
"type": "registry",
13+
"ref_prefix": "build-repo.stackable.tech:8083/sandbox/cache",
14+
"mode": "max",
15+
"compression": "zstd",
16+
"ignore-error": "true",
17+
},
18+
]

smoke/versions.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
versions = [
2+
{
3+
"product": "0.0.1",
4+
},
5+
{
6+
"product": "0.0.2",
7+
},
8+
]

0 commit comments

Comments
 (0)