Skip to content

start gh actions workflows #69

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

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from
Draft
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
276 changes: 276 additions & 0 deletions .github/workflows/wg-easy-pr-validation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,276 @@
---
name: WG-Easy PR Validation

on:
pull_request:
branches: [main]
paths:
- 'applications/wg-easy/**'
- '.github/workflows/wg-easy-pr-validation.yaml'
workflow_dispatch:
inputs:
test_mode:
description: 'Run in test mode'
required: false
default: 'true'

env:
APP_DIR: applications/wg-easy

jobs:
task-validation:
runs-on: ubuntu-22.04
defaults:
run:
working-directory: ${{ env.APP_DIR }}

strategy:
fail-fast: true
matrix:
task:
- dependencies-update
# - helm-preflight
- release-prepare
- clean

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Helm
uses: azure/setup-helm@v4
with:
version: '3.17.3'

- name: Setup Task
uses: arduino/setup-task@v2
with:
version: 3.x
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install kubectl
uses: azure/setup-kubectl@v4
with:
version: 'v1.30.0'

- name: Install preflight CLI
run: |
curl -L https://github.com/replicatedhq/troubleshoot/releases/latest/download/preflight_linux_amd64.tar.gz \
| tar xz
sudo mv preflight /usr/local/bin/

- name: Install yq
run: |
sudo wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 \
-O /usr/local/bin/yq
sudo chmod +x /usr/local/bin/yq

- name: Install Replicated CLI
run: task utils:install-replicated-cli

- name: Run task ${{ matrix.task }}
run: task ${{ matrix.task }}
timeout-minutes: 10
env:
REPLICATED_API_TOKEN: ${{ secrets.WG_EASY_REPLICATED_API_TOKEN }}
REPLICATED_APP: ${{ secrets.WG_EASY_REPLICATED_APP }}

- name: Verify release directory contents
if: matrix.task == 'release-prepare'
run: |
echo "Checking release directory contents:"
ls -la release/
echo "Verifying required files exist:"
test -f release/application.yaml
test -f release/config.yaml
test -f release/cluster.yaml
find release/ -name "*.tgz" | wc -l | grep -v "^0$"

- name: Upload release artifacts
if: matrix.task == 'release-prepare'
uses: actions/upload-artifact@v4
with:
name: wg-easy-release-${{ github.run_number }}
path: ${{ env.APP_DIR }}/release/
retention-days: 7

lint-and-validate:
runs-on: ubuntu-22.04
defaults:
run:
working-directory: ${{ env.APP_DIR }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Helm
uses: azure/setup-helm@v4
with:
version: '3.14.0'

- name: Setup Task
uses: arduino/setup-task@v2
with:
version: 3.x
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install yq
run: |
sudo wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 \
-O /usr/local/bin/yq
sudo chmod +x /usr/local/bin/yq

- name: Install Replicated CLI
run: task utils:install-replicated-cli

- name: Update dependencies
run: task dependencies-update
env:
REPLICATED_API_TOKEN: ${{ secrets.WG_EASY_REPLICATED_API_TOKEN }}
REPLICATED_APP: ${{ secrets.WG_EASY_REPLICATED_APP }}

- name: Lint Helm charts
run: |
for chart_dir in $(find charts/ -maxdepth 2 -name "Chart.yaml" | \
xargs dirname); do
echo "Linting chart: $chart_dir"
helm lint "$chart_dir"
done

- name: Template Helm charts
run: |
for chart_dir in $(find charts/ -maxdepth 2 -name "Chart.yaml" | \
xargs dirname); do
echo "Templating chart: $chart_dir"
helm template test-release "$chart_dir" --dry-run
done

- name: Validate Taskfile syntax
run: task --list-all

- name: Validate helmfile template
uses: helmfile/helmfile-action@v2.0.4
if: hashFiles('helmfile.yaml.gotmpl') != ''
with:
helmfile-args: build
helmfile-workdirectory: ${{ env.APP_DIR }}
env:
REPLICATED_APP: "test-app"
CHANNEL: "unstable"
REPLICATED_LICENSE_ID: "test-license"
TF_EXPOSED_URL: "test.example.com"

replicated-release:
runs-on: ubuntu-22.04
needs: task-validation
defaults:
run:
working-directory: ${{ env.APP_DIR }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Helm
uses: azure/setup-helm@v4
with:
version: '3.17.3'

- name: Setup Task
uses: arduino/setup-task@v2
with:
version: 3.x
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install kubectl
uses: azure/setup-kubectl@v4
with:
version: 'v1.30.0'

- name: Install yq
run: |
sudo wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 \
-O /usr/local/bin/yq
sudo chmod +x /usr/local/bin/yq

- name: Install Replicated CLI
run: task utils:install-replicated-cli

- name: Run replicated-release task
run: |
BRANCH_NAME="${{ github.head_ref || github.ref_name }}"
CHANNEL_NAME=$(echo "$BRANCH_NAME" | tr '[:upper:]' '[:lower:]')
task release-create
timeout-minutes: 15
env:
REPLICATED_API_TOKEN: ${{ secrets.WG_EASY_REPLICATED_API_TOKEN }}
REPLICATED_APP: ${{ secrets.WG_EASY_REPLICATED_APP }}
CHANNEL: $CHANNEL_NAME

create-customer:
runs-on: ubuntu-22.04
needs: replicated-release
defaults:
run:
working-directory: ${{ env.APP_DIR }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Task
uses: arduino/setup-task@v2
with:
version: 3.x
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install Replicated CLI
run: task utils:install-replicated-cli

- name: Create customer with branch name
run: |
BRANCH_NAME="${{ github.head_ref || github.ref_name }}"
CHANNEL_NAME=$(echo "$BRANCH_NAME" | tr '[:upper:]' '[:lower:]')
replicated customer create --name "$BRANCH_NAME" --channel "$CHANNEL_NAME"
timeout-minutes: 5
env:
REPLICATED_API_TOKEN: ${{ secrets.WG_EASY_REPLICATED_API_TOKEN }}
REPLICATED_APP: ${{ secrets.WG_EASY_REPLICATED_APP }}

- name: Create cluster with branch name
run: |
BRANCH_NAME="${{ github.head_ref || github.ref_name }}"
replicated cluster create --name "$BRANCH_NAME" --distribution embedded-cluster
timeout-minutes: 10
env:
REPLICATED_API_TOKEN: ${{ secrets.WG_EASY_REPLICATED_API_TOKEN }}
REPLICATED_APP: ${{ secrets.WG_EASY_REPLICATED_APP }}

cleanup:
runs-on: ubuntu-22.04
needs: [task-validation, lint-and-validate, replicated-release, create-customer]
if: always()
defaults:
run:
working-directory: ${{ env.APP_DIR }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Task
uses: arduino/setup-task@v2
with:
version: 3.x
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install Replicated CLI
run: task utils:install-replicated-cli

- name: Run clean task
run: task clean
timeout-minutes: 10
env:
REPLICATED_API_TOKEN: ${{ secrets.WG_EASY_REPLICATED_API_TOKEN }}
REPLICATED_APP: ${{ secrets.WG_EASY_REPLICATED_APP }}
10 changes: 10 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
extends: default

rules:
line-length:
max: 120
level: warning
truthy:
allowed-values: ['true', 'false', 'on', 'off', 'yes', 'no']
comments:
min-spaces-from-content: 1
28 changes: 28 additions & 0 deletions applications/wg-easy/Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,32 @@ tasks:
- cluster-create
- verify-kubeconfig

helm-repo-add:
desc: Add all HTTP/HTTPS Helm repositories found in Chart.yaml files
silent: false
run: once
cmds:
- echo "Adding Helm repositories from Chart.yaml files..."
- |
# Find all Chart.yaml files and extract HTTP/HTTPS repositories
for chart_file in $(find charts/ -maxdepth 2 -name "Chart.yaml"); do
echo "Processing $chart_file"

# Extract repository URLs that start with http:// or https://
yq eval '.dependencies[]?.repository' "$chart_file" 2>/dev/null | grep -E '^https?://' | while read -r repo_url; do
if [ -n "$repo_url" ]; then
# Generate a repository name from the URL
repo_name=$(echo "$repo_url" | sed 's|https\?://||' | sed 's|[./]|-|g' | sed 's|-*$||')

echo "Adding repository: $repo_name -> $repo_url"
helm repo add "$repo_name" "$repo_url" || echo "Repository $repo_name may already exist"
fi
done
done
- echo "Updating Helm repository index..."
- helm repo update
- echo "All Helm repositories added and updated!"

dependencies-update:
desc: Update Helm dependencies for all charts
silent: false
Expand All @@ -158,6 +184,8 @@ tasks:
helm dependency update --skip-refresh "$chart_dir"
done
- echo "All dependencies updated!"
deps:
- helm-repo-add

cluster-ports-expose:
desc: Expose configured ports for a cluster and capture exposed URLs
Expand Down
Loading
Loading