generated from kyma-project/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 8
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
2 changed files
with
147 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,108 @@ | ||
# This workflow will build a golang project | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go | ||
|
||
name: Test | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
tags: [ '*.*.*' ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
env: | ||
# Use docker.io for Docker Hub if empty | ||
REGISTRY: ghcr.io | ||
# github.repository as <account>/<repo> | ||
IMAGE_NAME: ${{ github.repository }} | ||
|
||
jobs: | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
permissions: write-all | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.19 | ||
cache: true | ||
|
||
- name: Build | ||
run: go build -v ./... | ||
|
||
- name: Test | ||
run: go test -v ./... | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
# Login against a Docker registry except on PR | ||
# https://github.com/docker/login-action | ||
- name: Log into registry ${{ env.REGISTRY }} | ||
if: github.event_name != 'pull_request' | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Extract Docker metadata | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
tags: | | ||
type=sha | ||
type=semver,pattern={{version}},event=tag | ||
- name: Build Docker image | ||
id: build-and-push | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
load: ${{ github.event_name == 'pull_request' }} | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
|
||
# - name: K3s test | ||
# run: | | ||
# curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION="v1.25.5+k3s1" K3S_KUBECONFIG_MODE=644 INSTALL_K3S_EXEC="server --docker --disable traefik" sh - | ||
# mkdir -p ~/.kube | ||
# cp /etc/rancher/k3s/k3s.yaml ~/.kube/config | ||
# chmod 600 ~/.kube/config | ||
# make install | ||
# make deploy IMG=$(echo $DOCKER_METADATA_OUTPUT_JSON | jq -r .tags[0]) | ||
# make test USE_EXISTING_CLUSTER=true | ||
# | ||
# | ||
# - name: Generate release artifacts | ||
# if: startsWith(github.ref, 'refs/tags/') | ||
# run: | | ||
# kubectl kustomize config/default >cluster-ip-operator.yaml | ||
# curl -Lo kyma https://storage.googleapis.com/kyma-cli-unstable/kyma-linux | ||
# chmod +x kyma | ||
# ./kyma alpha create module -n kyma-project.io/cluster-ip --version $GITHUB_REF_NAME \ | ||
# --registry ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-module \ | ||
# -o cluster-ip-module-template.yaml -v | ||
# | ||
# - name: Setup tmate session | ||
# if: failure() | ||
# uses: mxschmitt/action-tmate@v3 | ||
# with: | ||
# limit-access-to-actor: true | ||
# | ||
# - name: Release | ||
# uses: softprops/action-gh-release@v1 | ||
# if: startsWith(github.ref, 'refs/tags/') | ||
# with: | ||
# files: | | ||
# cluster-ip-operator.yaml | ||
# cluster-ip-module-template.yaml | ||
# |
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,39 @@ | ||
name: Code Quality | ||
on: | ||
push: | ||
tags: | ||
- v* | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
permissions: | ||
contents: read | ||
# Optional: allow read access to pull request. Use with `only-new-issues` option. | ||
pull-requests: read | ||
jobs: | ||
lint: | ||
name: lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/setup-go@v3 | ||
with: | ||
go-version: '1.19' | ||
- uses: actions/checkout@v3 | ||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v3 | ||
with: | ||
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version | ||
version: v1.51 | ||
args: --timeout=5m | ||
test: | ||
name: Unit Test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.20' | ||
- name: test | ||
run: go test ./... |