Skip to content
This repository has been archived by the owner on Aug 4, 2024. It is now read-only.

Commit

Permalink
fix: Init (#1)
Browse files Browse the repository at this point in the history
Co-authored-by: Zack Stevens <[email protected]>
  • Loading branch information
Zack Stevens and Zack Stevens authored Feb 17, 2022
1 parent 5b1a1a7 commit 8a09636
Show file tree
Hide file tree
Showing 3 changed files with 189 additions and 20 deletions.
6 changes: 0 additions & 6 deletions CHANGELOG.md

This file was deleted.

190 changes: 176 additions & 14 deletions action.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,183 @@
name: 'Hello World' # taken from https://docs.github.com/en/actions/creating-actions/creating-a-composite-action
description: 'Greet someone'
name: 'Kind Test'
description: 'Creates a kind cluster, installs helm charts, runs an app via skaffold, and runs tests'
inputs:
who-to-greet: # id of input
description: 'Who to greet'
required: true
default: 'World'
outputs:
random-number:
description: "Random number"
value: ${{ steps.random-number-generator.outputs.random-id }}
token:
description: 'Github token, if there are dependencies, this should be a PAT so that the other repos can be cloned'
required: false
default: ${{ github.token }}
ref:
description: 'Git ref to use'
required: false
default: ${{ github.ref }}
test-command:
description: 'What test command to run'
required: false
default: 'go test'
test-working-directory:
description: 'Directory to run tests from'
required: false
default: 'test'
wait-for-ports:
description: 'Ports to wait for, used for dependent charts, if those charts need exposed local ports as part of testing. Comma separated list such as `8000,8001`'
required: false
default: ''
max-wait:
description: 'Max time in milliseconds to wait for readiness on ports set in `wait-for-ports`'
required: false
default: 300000
check-interval:
description: 'Interval to check readiness on ports set in `wait-for-ports`'
required: false
default: 5000
helm-charts:
description: 'Helm charts to install, a json formatted string, that is a list of objects'
required: false
default: '[]'
credentials-json:
description: 'Gcloud service account credentials json. This is required if you are installing helm charts'
required: false
project-id:
description: 'gcloud project id. This is required if you are installing helm charts'
required: false
region:
description: 'artifact registry region'
required: false
default: 'us-west1'
repository:
description: 'artifact registry repository'
required: false
default: 'charts'
helm-install-wait-timeout:
description: 'How long to wait for installed charts to be healthy before failing'
required: false
default: 3m
dependencies:
description: 'Other git repos in this organization to clone and run skaffold for. Should be a comma separated list of short repository names, excluding the organization'
required: false
default: ''
sleep:
description: 'Seconds to sleep before running tests'
required: false
default: 10
helm-repo-name:
description: 'Helm repository name to add'
required: false
default: unsupervised
helm-repo-url:
description: 'Helm repository url'
required: false
default: 'https://raw.githubusercontent.com/${{ github.repository_owner }}/charts/main'
helm-repo-username:
description: 'Helm repository username'
required: false
default: ''
helm-repo-password:
description: 'Helm repository password'
required: false
default: ''
runs:
using: "composite"
steps:
- run: echo Hello ${{ inputs.who-to-greet }}.
- name: Checkout
uses: actions/checkout@v2
with:
token: ${{ inputs.token }}
ref: ${{ inputs.ref }}
path: app
- name: Setup Go
if: hashFiles('app/go.mod') != '' # rudimentary file existence check
uses: actions/setup-go@v2
with:
go-version: '1.17.x'
- name: Setup Go Cache
if: hashFiles('app/go.mod') != '' # rudimentary file existence check
uses: actions/cache@v2
with:
# * Module download cache
# * Build cache (Linux)
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Setup skaffold cache
uses: actions/cache@v2
with:
path: |
~/.skaffold/cache
key: ${{ runner.os }}-skaffold-${{ hashFiles('**/skaffold.yaml') }}
restore-keys: |
${{ runner.os }}-skaffold-
- name: Setup tools
uses: yokawasa/[email protected]
with:
helm: '3.7.2'
skaffold: '1.35.0'
- name: Add helm repository
shell: bash
- id: random-number-generator
run: echo "::set-output name=random-id::$(echo $RANDOM)"
run: |
helm repo add ${{ inputs.helm-repo-name}} ${{ inputs.helm-repo-url}} --username ${{ inputs.helm-repo-username }} --password ${{ inputs.helm-repo-password }}
- name: Set up Docker Buildx
uses: docker/[email protected]
- uses: google-github-actions/auth@v0
with:
credentials_json: ${{ inputs.credentials-json }}
- id: auth
uses: google-github-actions/auth@v0
with:
credentials_json: ${{ inputs.credentials-json }}
- name: Setup gcloud
uses: google-github-actions/[email protected]
with:
project_id: ${{ inputs.project-id }}
- name: Prepare for skaffold and tests
shell: bash
- run: ${{ github.action_path }}/goodbye.sh
run: |
git config --global url."https://${{ inputs.token }}@github.com".insteadOf "https://github.com"
gcloud auth configure-docker ${{ inputs.region }}-docker.pkg.dev
mkdir ${GITHUB_WORKSPACE}/skaffold-logs
- name: Create Kind cluster
uses: engineerd/[email protected]
with:
version: "v0.11.1"
- name: Run Dependencies
if: inputs.dependencies != ''
env:
GITHUB_TOKEN: ${{ inputs.token }}
HELM_EXPERIMENTAL_OCI: 1
GOOGLE_APPLICATION_CREDENTIALS: ${{steps.auth.outputs.credentials_file_path}}
shell: bash
run: ${{ github.action_path }}/run-dependencies.sh ${{ inputs.dependencies }}
- name: Run app via skaffold
env:
SKAFFOLD_ACTIONS: true
HELM_EXPERIMENTAL_OCI: 1
GOOGLE_APPLICATION_CREDENTIALS: ${{steps.auth.outputs.credentials_file_path}}
shell: bash
working-directory: app
run: |
skaffold run --tail --port-forward=user --verbosity=info > ${GITHUB_WORKSPACE}/skaffold-logs/app.txt &
- name: Wait for ready
if: inputs.wait-for-ports != ''
uses: Unsupervisedcom/action-wait-for-ports@v1
with:
ports: ${{ inputs.wait-for-ports }}
max-wait: ${{ inputs.max-wait }}
check-interval: ${{ inputs.check-interval }}
- name: Run tests
shell: bash
working-directory: app/${{ inputs.test-working-directory }}
run: |
sleep ${{ inputs.sleep }}
${{ inputs.test-command }}
- name: Report status on failure
if: failure()
shell: bash
run: |
kubectl get all --all-namespaces
for i in ${GITHUB_WORKSPACE}/skaffold-logs/*.txt
do
echo "logs for $i"
cat $i
done
13 changes: 13 additions & 0 deletions run-dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
set -e

dependencies=$1

mkdir dependencies && cd dependencies

for i in ${dependencies//,/ }
do
git clone https://${GITHUB_TOKEN}@github.com/Unsupervisedcom/${i}.git
cd $i
skaffold run --tail --port-forward=user --verbosity=info > ${GITHUB_WORKSPACE}/skaffold-logs/${i}.txt &
done

0 comments on commit 8a09636

Please sign in to comment.