Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(e2e): set exact commit sha to use for e2e images #1149

Merged
merged 5 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/e2e-k3d.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
- "kubernetes/**"
- "preprocessing/**"
- "deploy.py"
- ".github/workflows/e2e-test.yml"
- ".github/workflows/e2e-k3d.yml"

concurrency:
group: ci-${{ github.ref }}-e2e-k3d
Expand All @@ -34,7 +34,7 @@ jobs:

- name: Create k3d cluster
run: |
./deploy.py cluster
./deploy.py --verbose cluster

- name: Test helm template
uses: WyriHaximus/github-action-helm3@v3
Expand Down Expand Up @@ -82,21 +82,21 @@ jobs:
- name: Wait for Backend Docker Image
uses: lewagon/[email protected]
with:
ref: ${{ github.ref }}
ref: ${{ github.sha }}
check-name: Build Backend Docker Image
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Wait for Website Docker Image
uses: lewagon/[email protected]
with:
ref: ${{ github.ref }}
ref: ${{ github.sha }}
check-name: Build Website Docker Image
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Deploy with helm
uses: WyriHaximus/github-action-helm3@v3
with:
exec: ./deploy.py helm --branch ${{ github.ref_name }} --dockerconfigjson ${{ secrets.GHCR_DOCKER_CONFIG }}
exec: ./deploy.py --verbose helm --branch ${{ github.ref_name }} --sha ${{ github.sha }} --dockerconfigjson ${{ secrets.GHCR_DOCKER_CONFIG }}

- name: Wait for the pods to be ready
run: ./.github/scripts/wait_for_pods_to_be_ready.py
Expand Down
11 changes: 9 additions & 2 deletions deploy.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/usr/bin/env python3

import argparse
import os
import subprocess
import time
from pathlib import Path
import os

import yaml

script_path = Path(__file__).resolve()
Expand All @@ -28,6 +29,7 @@
parser = argparse.ArgumentParser(description='Manage k3d cluster and helm installations.')
subparsers = parser.add_subparsers(dest='subcommand', required=True, help='Subcommands')
parser.add_argument('--dry-run', action='store_true', help='Print commands instead of executing them')
parser.add_argument('--verbose', action='store_true', help='Print commands that are executed')

cluster_parser = subparsers.add_parser('cluster', help='Start the k3d cluster')
cluster_parser.add_argument('--dev', action='store_true',
Expand All @@ -38,6 +40,7 @@
helm_parser.add_argument('--dev', action='store_true',
help='Set up a development environment for running the website and the backend locally')
helm_parser.add_argument('--branch', help='Set the branch to deploy with the Helm chart')
helm_parser.add_argument('--sha', help='Set the commit sha to deploy with the Helm chart')
helm_parser.add_argument('--dockerconfigjson',
help='Set the base64 encoded dockerconfigjson secret for pulling the images')
helm_parser.add_argument('--uninstall', action='store_true', help='Uninstall installation')
Expand All @@ -53,11 +56,12 @@
args = parser.parse_args()

def run_command(command: list[str], **kwargs):
if args.dry_run:
if args.dry_run or args.verbose:
if isinstance(command, str):
print(command)
else:
print(" ".join(map(str,command)))
if args.dry_run:
return subprocess.CompletedProcess(args=command, returncode=0, stdout="", stderr="")
else:
return subprocess.run(command, **kwargs)
Expand Down Expand Up @@ -141,6 +145,9 @@ def handle_helm():
'--set', f"dockerconfigjson={docker_config_json}",
]

if args.sha:
parameters += ['--set', f"sha={args.sha[:7]}"]

if args.dev:
parameters += ['--set', "disableBackend=true"]
parameters += ['--set', "disableWebsite=true"]
Expand Down
Loading