-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #351 from kbst/test-matrix
Run variants in parallel
- Loading branch information
Showing
10 changed files
with
142 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
FROM python:3 | ||
|
||
COPY src/ /opt/get-matrix/ | ||
|
||
CMD ["python", "/opt/get-matrix/main.py"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
name: "Get Matrix for Catalog Build" | ||
description: "Get test matrix based on build action output." | ||
runs: | ||
using: 'docker' | ||
image: 'Dockerfile' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/usr/bin/env python3 | ||
|
||
from json import dumps | ||
from os import environ, listdir | ||
from os.path import isdir, isfile, join | ||
from shutil import unpack_archive | ||
from sys import exit | ||
from tempfile import TemporaryDirectory | ||
|
||
DISTDIR = "_dist" | ||
|
||
|
||
if __name__ == '__main__': | ||
output = { | ||
"include": [] | ||
} | ||
|
||
for name in listdir(DISTDIR): | ||
if not isfile(name) and (not name.startswith('module-') or not name.endswith('.zip')): | ||
continue | ||
|
||
with TemporaryDirectory() as root: | ||
mut = join(root, "mut") | ||
archive = join(DISTDIR, name) | ||
unpack_archive(archive, mut, "zip") | ||
for variant in listdir(mut): | ||
variant_path = join(mut, variant) | ||
if not isdir(variant_path): | ||
continue | ||
|
||
output["include"].append({ | ||
"variant": variant, | ||
"name": name | ||
}) | ||
|
||
outputsFile = environ.get('GITHUB_OUTPUT') | ||
outputData = dumps(output) | ||
|
||
if outputsFile: | ||
with open(outputsFile, 'w') as f: | ||
f.write(f'matrix={outputData}') | ||
exit(0) | ||
|
||
print(outputData) | ||
exit(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
name: Build | ||
run-name: 'Build & test :: ${{ github.ref }}' | ||
|
||
on: | ||
push: | ||
|
@@ -18,15 +19,15 @@ jobs: | |
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3.0.0 | ||
- uses: actions/checkout@v4.0.0 | ||
|
||
# Run builder | ||
- name: Run builder | ||
uses: ./.github/actions/builder | ||
|
||
# Upload artifacts | ||
- name: 'Upload artifacts' | ||
uses: actions/upload-artifact@v3.0.0 | ||
uses: actions/upload-artifact@v3.1.3 | ||
with: | ||
name: _dist | ||
path: _dist/*.zip | ||
|
@@ -40,7 +41,7 @@ jobs: | |
|
||
steps: | ||
# Checkout | ||
- uses: actions/checkout@v3.0.0 | ||
- uses: actions/checkout@v4.0.0 | ||
|
||
# Setup Terraform | ||
- name: Setup Terraform | ||
|
@@ -57,13 +58,36 @@ jobs: | |
# | ||
# | ||
# Test deploy to k3d | ||
test-k3d: | ||
get-matrix: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
|
||
outputs: | ||
matrix: ${{ steps.get-matrix.outputs.matrix }} | ||
|
||
steps: | ||
- uses: actions/[email protected] | ||
|
||
- name: 'Download build-artifacts' | ||
uses: actions/[email protected] | ||
with: | ||
name: _dist | ||
path: _dist | ||
|
||
- id: get-matrix | ||
uses: ./.github/actions/get-matrix | ||
|
||
test-k3d: | ||
runs-on: ubuntu-latest | ||
needs: get-matrix | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: ${{ fromJSON(needs.get-matrix.outputs.matrix) }} | ||
|
||
steps: | ||
# Checkout | ||
- uses: actions/checkout@v3.0.0 | ||
- uses: actions/checkout@v4.0.0 | ||
|
||
# Setup k3d | ||
- name: Setup k3d | ||
|
@@ -76,18 +100,14 @@ jobs: | |
|
||
# Download build artifacts | ||
- name: 'Download build-artifacts' | ||
uses: actions/download-artifact@v2 | ||
uses: actions/download-artifact@v3.0.2 | ||
with: | ||
name: _dist | ||
path: _dist | ||
|
||
# Build test image | ||
- name: Build test image | ||
run: docker build -t test-k3d test/k3d/ | ||
|
||
# Deploy to cluster | ||
- name: Run test container | ||
run: docker run --network host --rm -v `pwd`/_dist:/_dist -v $HOME/.kube/config:/opt/test/.kubeconfig test-k3d | ||
run: make test-k3d test-name=${{ matrix.name }} test-variant=${{ matrix.variant}} | ||
|
||
|
||
# | ||
|
@@ -100,15 +120,17 @@ jobs: | |
steps: | ||
# Download build artifacts | ||
- name: 'Download build-artifacts' | ||
uses: actions/[email protected].0 | ||
uses: actions/[email protected].2 | ||
with: | ||
name: _dist | ||
path: _dist | ||
|
||
# Upload archive | ||
- uses: google-github-actions/[email protected].1 | ||
- uses: google-github-actions/[email protected].1 | ||
with: | ||
service_account_key: ${{ secrets.GCLOUD_AUTH }} | ||
credentials_json: '${{ secrets.GCLOUD_AUTH }}' | ||
|
||
- uses: google-github-actions/[email protected] | ||
|
||
- run: gsutil -m cp _dist/*.zip gs://dev.catalog.kubestack.com | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
name: Promote | ||
run-name: 'Promote :: ${{ github.ref }}' | ||
|
||
on: workflow_dispatch | ||
|
||
|
@@ -15,9 +16,11 @@ jobs: | |
|
||
steps: | ||
# Setup gcloud CLI | ||
- uses: google-github-actions/[email protected].1 | ||
- uses: google-github-actions/[email protected].1 | ||
with: | ||
service_account_key: ${{ secrets.GCLOUD_AUTH }} | ||
credentials_json: '${{ secrets.GCLOUD_AUTH }}' | ||
|
||
- uses: google-github-actions/[email protected] | ||
|
||
# Promote archive | ||
- run: | | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
FROM kubestack/framework:v0.18.0-beta.0-kind | ||
FROM kubestack/framework:v0.19.1-beta.0-kind | ||
|
||
COPY Pipfile Pipfile.lock /opt/ | ||
WORKDIR /opt | ||
|
||
RUN pip install --no-cache-dir pipenv &&\ | ||
PIPENV_VENV_IN_PROJECT=true pipenv install | ||
|
||
COPY main.tf.tpl test.py /opt/test/ | ||
COPY main.tf.tpl main.py /opt/test/ | ||
|
||
ENV PATH=/opt/.venv/bin:$PATH \ | ||
KUBECONFIG=/opt/test/.kubeconfig \ | ||
KUBECONFIG_PATH=/opt/test/.kubeconfig | ||
|
||
WORKDIR /opt/test | ||
CMD ["nosetests", "-s", "--logging-level", "WARNING", "test.py"] | ||
ENTRYPOINT ["python", "main.py"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,6 @@ verify_ssl = true | |
[dev-packages] | ||
|
||
[packages] | ||
nose = "*" | ||
kubernetes = "*" | ||
jinja2 = "*" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters