Skip to content

Commit

Permalink
Merge pull request #1 from cybozu-go/init
Browse files Browse the repository at this point in the history
Implement cattage
  • Loading branch information
zoetrope authored Feb 10, 2022
2 parents d62f50e + 63e8e08 commit faae99a
Show file tree
Hide file tree
Showing 126 changed files with 8,255 additions and 36 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/config
/docs
/e2e
/hack
/.git
/dist
14 changes: 14 additions & 0 deletions .github/actions/aqua/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: "Setup tools"
description: "Setup tools with aqua"
inputs:
github_token:
description: "GitHub Token"
required: true
runs:
using: composite
steps:
- uses: aquaproj/aqua-installer@58fc6b885cba1f956127fa2b40d64eea0400bf7b #v0.7.0
with:
aqua_version: v0.10.2
env:
GITHUB_TOKEN: ${{ inputs.github_token }}
93 changes: 92 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,31 @@ on:
branches:
- 'main'
env:
go-version: 1.16
go-version: 1.17
cache-version: 1
jobs:
build:
name: Build binaries
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: ${{ env.go-version }}
- run: make build
check-goreleaser-config:
name: Check goreleaser.yml
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Setup go
uses: actions/setup-go@v2
with:
go-version: ${{ env.go-version }}
- uses: goreleaser/goreleaser-action@79d4afbba1b4eff8b9a98e3d2e58c4dbaf094e2b # v2.8.1
with:
version: latest
args: check -f .goreleaser.yml
test:
name: Small tests
runs-on: ubuntu-20.04
Expand All @@ -16,4 +38,73 @@ jobs:
- uses: actions/setup-go@v2
with:
go-version: ${{ env.go-version }}
- uses: ./.github/actions/aqua
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- run: make test
- run: make check-generate
- run: make envtest
e2e:
name: End-to-End Tests
strategy:
matrix:
k8s-version: ["1.22.4", "1.23.1"]
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: ${{ env.go-version }}
- uses: ./.github/actions/aqua
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- run: make start KUBERNETES_VERSION=${{ matrix.k8s-version }}
working-directory: e2e
- run: make test
working-directory: e2e
- run: make logs
working-directory: e2e
if: always()
- uses: actions/upload-artifact@v2
if: always()
with:
name: logs-${{ matrix.k8s-version }}.tar.gz
path: e2e/logs.tar.gz
tilt:
name: Run tilt ci
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: ${{ env.go-version }}
- uses: ./.github/actions/aqua
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- run: make controller-gen
- run: make dev
- run: tilt ci
dry-run:
name: Dry-run release
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: docker/setup-qemu-action@v1
- uses: docker/setup-buildx-action@v1
- name: Setup go
uses: actions/setup-go@v2
with:
go-version: ${{ env.go-version }}
- name: GoReleaser
uses: goreleaser/goreleaser-action@79d4afbba1b4eff8b9a98e3d2e58c4dbaf094e2b # v2.8.1
with:
version: latest
args: --snapshot --skip-publish --rm-dist
- uses: ./.github/actions/aqua
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Test built containers
run: make container-structure-test
65 changes: 65 additions & 0 deletions .github/workflows/helm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Release Charts
on:
push:
tags:
- 'chart-v*'
jobs:
build:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: ./.github/actions/aqua
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Check chart version
run: |
tag_version=${GITHUB_REF##*/chart-v}
chart_version=$(cat charts/cattage/Chart.yaml | grep 'version:' | sed 's/version:\s//')
if [ "$tag_version" != "$chart_version" ]; then
echo "Different versions: tag \"$tag_version\", chart \"$chart_version\""
exit 1
fi
- name: Packaging the chart
run: helm package ./charts/cattage/
- uses: actions/upload-artifact@v2
with:
name: helm-charts
path: ./cattage-*.tgz
retention-days: 1
publish:
name: Publish charts on GitHub Pages
runs-on: ubuntu-20.04
needs: build
steps:
- uses: actions/checkout@v2
with:
ref: gh-pages
- uses: ./.github/actions/aqua
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/download-artifact@v2
with:
name: helm-charts
- name: Update charts index
run: helm repo index --url https://cybozu-go.github.io/cattage/ --merge index.yaml .
- run: git add .
- name: Check diffs
run: |
diffs=$(git status -s)
if [ "$diffs" = "" ]; then
echo "NO_DIFF=1" >> $GITHUB_ENV
else
printf "%s\n" "$diffs"
fi
- name: Commit changes
if: env.NO_DIFF != '1'
run: |
git config --global user.name 'Cybozu Neco'
git config --global user.email '[email protected]'
git commit -m 'update'
- name: Push to gh-pages
if: env.NO_DIFF != '1'
run: git push origin gh-pages
6 changes: 5 additions & 1 deletion .github/workflows/mdbook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/aqua
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- run: make book
- uses: actions/upload-artifact@v2
with:
Expand All @@ -24,7 +27,8 @@ jobs:
- uses: actions/checkout@v2
with:
ref: gh-pages
- run: rm -rf *
# ignore helm chart index file and chart archive file.
- run: ls | grep -v -E 'index.yaml|.*\.tgz' | xargs rm -rf
- uses: actions/download-artifact@v2
with:
name: book
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Release
on:
push:
tags:
- 'v*'
env:
go-version: 1.17
jobs:
release:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: docker/setup-qemu-action@v1
- uses: docker/setup-buildx-action@v1
- name: GHCR Login
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Setup go
uses: actions/setup-go@v2
with:
go-version: ${{ env.go-version }}
- name: GoReleaser
uses: goreleaser/goreleaser-action@79d4afbba1b4eff8b9a98e3d2e58c4dbaf094e2b # v2.8.1
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14 changes: 9 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# Test binary, build with `go test -c`
*.test
/test

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

# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736
.glide/

# Editors
*~
.*.swp
Expand All @@ -15,6 +13,12 @@
/.vscode
/.idea

# Generated files
# Binaries
/bin
/docs/book
/build
/dist

# go mod
/vendor

/tilt_modules
55 changes: 55 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
project_name: cattage
dist: bin/
builds:
- env:
- CGO_ENABLED=0
main: ./cmd/cattage-controller
binary: cattage-controller
goos:
- linux
goarch:
- amd64
- arm64
dockers:
- image_templates:
- "ghcr.io/cybozu-go/{{.ProjectName}}:{{ .Version }}-amd64"
use: buildx
dockerfile: Dockerfile
extra_files:
- LICENSE
build_flag_templates:
- "--platform=linux/amd64"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- image_templates:
- "ghcr.io/cybozu-go/{{.ProjectName}}:{{ .Version }}-arm64"
use: buildx
goarch: arm64
dockerfile: Dockerfile
extra_files:
- LICENSE
build_flag_templates:
- "--platform=linux/arm64"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
docker_manifests:
- name_template: "ghcr.io/cybozu-go/{{.ProjectName}}:{{ .Version }}"
image_templates:
- "ghcr.io/cybozu-go/{{.ProjectName}}:{{ .Version }}-amd64"
- "ghcr.io/cybozu-go/{{.ProjectName}}:{{ .Version }}-arm64"
- name_template: "ghcr.io/cybozu-go/{{.ProjectName}}:{{ .Major }}.{{ .Minor }}"
image_templates:
- "ghcr.io/cybozu-go/{{.ProjectName}}:{{ .Version }}-amd64"
- "ghcr.io/cybozu-go/{{.ProjectName}}:{{ .Version }}-arm64"
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM scratch
LABEL org.opencontainers.image.authors="Cybozu, Inc." \
org.opencontainers.image.title="cattage" \
org.opencontainers.image.source="https://github.com/cybozu-go/cattage"
WORKDIR /
COPY LICENSE /
COPY cattage-controller /
USER 65532:65532

ENTRYPOINT ["/cattage-controller"]
Loading

0 comments on commit faae99a

Please sign in to comment.