Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
Signed-off-by: Danielle Lancashire <dani@builds.terrible.systems>
  • Loading branch information
endocrimes committed Feb 1, 2024
0 parents commit a6638e6
Show file tree
Hide file tree
Showing 165 changed files with 10,163 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# More info: https://docs.docker.com/engine/reference/builder/#dockerignore-file
# Ignore build and test binaries.
bin/
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake;
9 changes: 9 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# CODEOWNERS
# https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners

# NOTE: Order is important; the last matching pattern takes the most precedence. When someone opens a pull request that
# only modifies files under a certain matching pattern, only those code owners will be requested for a review.

# These owners will be the default owners for everything in the repository. Unless a later match takes precedence, they
# will be requested for review when someone opens a pull request.
* @calebschoepp @endocrimes @lann @michelleN
13 changes: 13 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "weekly"
111 changes: 111 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
name: Go Build and Test

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

permissions:
contents: read
pull-requests: write
packages: read

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.21.x'
cache: true

- name: Setup gotestsum
uses: autero1/action-gotestsum@v2.0.0
with:
gotestsum_version: "1.8.2"

- name: Install dependencies
run: go mod download

- name: Build
run: CGO_ENABLED=0 go build -v ./...

- name: Setup EnvTest
run: make envtest

- name: Test
run: |
mkdir .results
gotestsum \
--junitfile .results/results.xml \
--jsonfile .results/results.json \
--format testname \
-- -coverprofile=.results/cover.out ./...
- name: Test Summary
uses: test-summary/action@v2
with:
paths: ".results/results.xml"
if: always()
- name: Upload test results
uses: actions/upload-artifact@v4
with:
name: results.xml
path: ./.results/results.xml
if: always()
- name: Upload test coverage
uses: actions/upload-artifact@v4
with:
name: cover.out
path: ./.results/cover.out
if: always()
- name: Upload Go test results json
uses: actions/upload-artifact@v4
with:
name: results.json
path: ./.results/results.json

lint_go:
name: lint go
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v5
with:
go-version: '1.21.x'
- uses: actions/checkout@v4
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.55.2
args: --timeout=10m

lint_shell:
name: lint shell
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master

lint_chart:
name: lint chart
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.21.x'
cache: true
- name: Install dependencies
run: go mod download
- name: Install helm
uses: Azure/setup-helm@v3
with:
version: v3.14.0
- name: Lint chart
run: make helm-lint

77 changes: 77 additions & 0 deletions .github/workflows/container.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Docker

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
docker:
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup version info
run: echo "VERSION=$(date +%Y%m%d-%H%M%S)-g$(git rev-parse --short HEAD)" >> $GITHUB_ENV

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and Push PR - Ephemeral
uses: docker/build-push-action@v5
if: github.event_name == 'pull_request'
with:
context: .
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
tags: |
ttl.sh/spoopy-operator-pr-${{ github.event.pull_request.number }}:24h
- uses: mshick/add-pr-comment@v2
if: (github.event_name == 'pull_request') && ${{ success() }}
with:
message: |
This PR now has an image available for testing:
```
ttl.sh/spoopy-operator-pr-${{ github.event.pull_request.number }}:24h
```
- name: Build and Push
uses: docker/build-push-action@v5
if: github.event_name != 'pull_request'
with:
context: .
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
tags: |
ghcr.io/spinkube/spin-operator:${{ env.VERSION }}
24 changes: 24 additions & 0 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Documentation

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
lint-markdown:
name: Lint all markdown files
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Lint markdown
run: |
make lint-markdown
42 changes: 42 additions & 0 deletions .github/workflows/sample-apps.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Publish Sample Apps

on:
push:
branches:
- main

env:
REGISTRY: ghcr.io

jobs:
publish-image:
name: Publish sample app images
runs-on: ubuntu-latest
strategy:
matrix:
app: [cpu-load-gen, hello-world]
env:
IMAGE_NAME: ${{ github.repository }}

steps:
- uses: actions/checkout@v4

- name: Set the release version
shell: bash
run: |
echo "RELEASE_VERSION=$(date +%Y%m%d-%H%M%S)-g$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- name: Install Spin
uses: fermyon/actions/spin/setup@v1

- name: Install TinyGo
uses: acifani/setup-tinygo@v2

- name: Build and push versioned image
uses: fermyon/actions/spin/push@v1
with:
registry: ${{ env.REGISTRY }}
registry_username: ${{ github.actor }}
registry_password: ${{ secrets.GITHUB_TOKEN }}
registry_reference: "ghcr.io/spinkube/spin-operator/${{ matrix.app }}:${{ env.RELEASE_VERSION }}"
manifest_file: apps/${{ matrix.app }}/spin.toml
55 changes: 55 additions & 0 deletions .github/workflows/smoketest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Smoketest

on:
pull_request:
branches: [main]

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "1.21.x"

- name: setup k3d
uses: engineerd/configurator@v0.0.10
with:
name: k3d
url: https://github.com/k3d-io/k3d/releases/download/v5.6.0/k3d-linux-amd64

- name: start k3d cluster
run: |
k3d cluster create wasm-cluster \
--image ghcr.io/deislabs/containerd-wasm-shims/examples/k3d:v0.10.0 \
--port "8081:80@loadbalancer" \
--agents 2
- name: apply runtime class
run: kubectl apply -f spin-runtime-class.yaml

- name: start controller
timeout-minutes: 5
run: |
make install
make run &
timeout 300s bash -c 'until curl -s http://localhost:8082/healthz; do echo "waiting for controller to start"; sleep 2; done'
echo ""
echo "controller started successfully"
- name: run spin app
run: |
kubectl apply -f config/samples/shim-executor.yaml
kubectl apply -f config/samples/simple.yaml
kubectl rollout status deployment simple-spinapp --timeout 90s
kubectl port-forward svc/simple-spinapp 8083:80 &
timeout 15s bash -c 'until curl -f -vvv http://localhost:8083/hello; do sleep 2; done'
- name: Verify curl
run: curl localhost:8083/hello
31 changes: 31 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
bin/*
Dockerfile.cross

# Test binary, build with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Kubernetes Generated files - skip generated files, except for vendored files

!vendor/**/zz_generated.*

# editor and IDE paraphernalia
.idea
.vscode
*.swp
*.swo
*~
.direnv/

# Helm chart dependencies

charts/spin-operator/charts
Loading

0 comments on commit a6638e6

Please sign in to comment.