-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
222 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
name: Test for PR | ||
|
||
on: pull_request | ||
|
||
env: | ||
IMAGE_NAME: worker | ||
IMAGE_TAG: latest | ||
|
||
jobs: | ||
test: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- uses: actions/setup-go@v1 | ||
with: | ||
go-version: "1.13" | ||
- name: setup env | ||
run: | | ||
echo "::set-env name=GOPATH::$(go env GOPATH)" | ||
echo "::add-path::$(go env GOPATH)/bin" | ||
shell: bash | ||
- name: Install go tools | ||
run: cat tools.go | grep _ | awk -F '"' '{print $2}' | xargs -tI {} go install {} | ||
- name: go generate | ||
run: go generate ./... | ||
- name: Check uncommitted changes | ||
run: | | ||
if [ -n "$(git status --porcelain)" ]; then | ||
echo "uncommitted changes" | ||
git status | ||
exit 1 | ||
fi | ||
- name: go lint | ||
run: go list ./... | xargs golint -set_exit_status | ||
- run: go vet ./... | ||
- run: go test -v -race ./... | ||
|
||
docker: | ||
name: Build docker image | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Shellcheck | ||
env: | ||
SHELLCHECK_OPTS: -e SC2187 | ||
run: find . -name "*.sh" | xargs shellcheck | ||
- name: Lint | ||
run: | | ||
docker run -v $(pwd):/working --rm hadolint/hadolint \ | ||
hadolint /working/Dockerfile \ | ||
--ignore DL3018 | ||
- name: Build docker image | ||
run: docker build -t "docker.pkg.github.com/${GITHUB_REPOSITORY}/${IMAGE_NAME}:${IMAGE_TAG}" . | ||
- name: Install trivy | ||
run: | | ||
sudo apt-get install --no-install-recommends apt-transport-https gnupg lsb-release | ||
wget -qO - https://aquasecurity.github.io/trivy-repo/deb/public.key | sudo apt-key add - | ||
echo deb https://aquasecurity.github.io/trivy-repo/deb $(lsb_release -sc) main | sudo tee -a /etc/apt/sources.list.d/trivy.list | ||
sudo apt-get update | ||
sudo apt-get install --no-install-recommends trivy | ||
- name: Vulnerability Scan | ||
run: | | ||
trivy -q --severity HIGH,CRITICAL --exit-code 1 \ | ||
"docker.pkg.github.com/${GITHUB_REPOSITORY}/${IMAGE_NAME}:${IMAGE_TAG}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
name: Test on master | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
env: | ||
IMAGE_NAME: worker | ||
IMAGE_TAG: latest | ||
|
||
jobs: | ||
test: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- uses: actions/setup-go@v1 | ||
with: | ||
go-version: "1.13" | ||
- name: setup env | ||
run: | | ||
echo "::set-env name=GOPATH::$(go env GOPATH)" | ||
echo "::add-path::$(go env GOPATH)/bin" | ||
shell: bash | ||
- name: Install go tools | ||
run: cat tools.go | grep _ | awk -F '"' '{print $2}' | xargs -tI {} go install {} | ||
- name: go generate | ||
run: go generate ./... | ||
- name: Check uncommitted changes | ||
run: | | ||
if [ -n "$(git status --porcelain)" ]; then | ||
echo "uncommitted changes" | ||
git status | ||
exit 1 | ||
fi | ||
- name: go lint | ||
run: go list ./... | xargs golint -set_exit_status | ||
- run: go vet ./... | ||
- run: go test -v -race ./... | ||
|
||
docker: | ||
needs: test | ||
name: Build and push docker image | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Shellcheck | ||
env: | ||
SHELLCHECK_OPTS: -e SC2187 | ||
run: find . -name "*.sh" | xargs shellcheck | ||
- name: Lint | ||
run: | | ||
docker run -v $(pwd):/working --rm hadolint/hadolint \ | ||
hadolint /working/Dockerfile \ | ||
--ignore DL3018 | ||
- name: Build docker image | ||
run: docker build -t "docker.pkg.github.com/${GITHUB_REPOSITORY}/${IMAGE_NAME}:${IMAGE_TAG}" . | ||
- name: Install trivy | ||
run: | | ||
sudo apt-get install --no-install-recommends apt-transport-https gnupg lsb-release | ||
wget -qO - https://aquasecurity.github.io/trivy-repo/deb/public.key | sudo apt-key add - | ||
echo deb https://aquasecurity.github.io/trivy-repo/deb $(lsb_release -sc) main | sudo tee -a /etc/apt/sources.list.d/trivy.list | ||
sudo apt-get update | ||
sudo apt-get install --no-install-recommends trivy | ||
- name: Vulnerability Scan | ||
run: | | ||
trivy -q --severity HIGH,CRITICAL --exit-code 1 \ | ||
"docker.pkg.github.com/${GITHUB_REPOSITORY}/${IMAGE_NAME}:${IMAGE_TAG}" | ||
- name: Push docker image | ||
run: | | ||
echo "${{ secrets.GITHUB_TOKEN }}" | docker login -u owner --password-stdin docker.pkg.github.com | ||
docker push "docker.pkg.github.com/${GITHUB_REPOSITORY}/worker:${IMAGE_TAG}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- v[0-9]+.[0-9]+.[0-9]+ | ||
|
||
env: | ||
IMAGE_NAME: worker | ||
|
||
jobs: | ||
test: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- uses: actions/setup-go@v1 | ||
with: | ||
go-version: "1.13" | ||
- name: setup env | ||
run: | | ||
echo "::set-env name=GOPATH::$(go env GOPATH)" | ||
echo "::add-path::$(go env GOPATH)/bin" | ||
shell: bash | ||
- name: Install go tools | ||
run: cat tools.go | grep _ | awk -F '"' '{print $2}' | xargs -tI {} go install {} | ||
- name: go generate | ||
run: go generate ./... | ||
- name: Check uncommitted changes | ||
run: | | ||
if [ -n "$(git status --porcelain)" ]; then | ||
echo "uncommitted changes" | ||
git status | ||
exit 1 | ||
fi | ||
- name: go lint | ||
run: go list ./... | xargs golint -set_exit_status | ||
- run: go vet ./... | ||
- run: go test -v -race ./... | ||
|
||
docker: | ||
needs: test | ||
name: Build and push docker image | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Set image tag | ||
run: | | ||
tag=$(echo "${GITHUB_REF}" | sed "s/^refs\/tags\/v//") | ||
if [ -z "$tag" ]; then | ||
exit 1 | ||
fi | ||
echo "::set-env name=IMAGE_TAG::$tag" | ||
- name: Shellcheck | ||
env: | ||
SHELLCHECK_OPTS: -e SC2187 | ||
run: find . -name "*.sh" | xargs shellcheck | ||
- name: Lint | ||
run: | | ||
docker run -v $(pwd):/working --rm hadolint/hadolint \ | ||
hadolint /working/Dockerfile \ | ||
--ignore DL3018 | ||
- name: Build docker image | ||
run: docker build -t "docker.pkg.github.com/${GITHUB_REPOSITORY}/${IMAGE_NAME}:${IMAGE_TAG}" . | ||
- name: Install trivy | ||
run: | | ||
sudo apt-get install --no-install-recommends apt-transport-https gnupg lsb-release | ||
wget -qO - https://aquasecurity.github.io/trivy-repo/deb/public.key | sudo apt-key add - | ||
echo deb https://aquasecurity.github.io/trivy-repo/deb $(lsb_release -sc) main | sudo tee -a /etc/apt/sources.list.d/trivy.list | ||
sudo apt-get update | ||
sudo apt-get install --no-install-recommends trivy | ||
- name: Vulnerability Scan | ||
run: | | ||
trivy -q --severity HIGH,CRITICAL --exit-code 1 \ | ||
"docker.pkg.github.com/${GITHUB_REPOSITORY}/${IMAGE_NAME}:${IMAGE_TAG}" | ||
- name: Push docker image | ||
run: | | ||
echo "${{ secrets.GITHUB_TOKEN }}" | docker login -u owner --password-stdin docker.pkg.github.com | ||
docker push "docker.pkg.github.com/${GITHUB_REPOSITORY}/worker:${IMAGE_TAG}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
.* | ||
!.github | ||
!.gitignore | ||
!.dockerignore | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,6 @@ | |
package calendar | ||
|
||
import ( | ||
_ "golang.org/x/lint/golint" | ||
_ "golang.org/x/tools/cmd/stringer" | ||
) |