Skip to content

Commit

Permalink
Merge pull request #5 from AppsFlyer/add_github_actions_tal
Browse files Browse the repository at this point in the history
Add GitHub actions Tal
  • Loading branch information
tal-asulin authored Oct 22, 2023
2 parents 79d1c63 + e26fc76 commit b7a4e95
Show file tree
Hide file tree
Showing 7 changed files with 292 additions and 4 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/golang_integration_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Go Integration Test

on:
push:
branches-ignore:
- main
- master
pull_request:
branches:
- main
- master
release:

jobs:
integration-test:
name: integration-test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup go
uses: actions/setup-go@v4
with:
go-version-file: './go.mod'

# - name: Download envtest setup script
# run: curl -sSLo setup-envtest.sh https://raw.githubusercontent.com/kubernetes-sigs/controller-runtime/master/hack/setup-envtest.sh

# - name: Make the script executable
# run: chmod +x setup-envtest.sh

# - name: Setup envtest
# run: ./setup-envtest.sh

# - name: Install Controller-gen
# run: GO111MODULE=on go get sigs.k8s.io/controller-tools/cmd/[email protected]

# - name: Install Kustomize
# run: curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash

- name: Create k8s Kind Cluster
uses: helm/[email protected]
with:
config: test/kind/config.yml
cluster_name: test-cluster

- name: run integration tests
run: make integration-test
- uses: actions/upload-artifact@v3
with:
name: integration_coverage_report
path: integration-test-cover.out

# coverage:
# name: Coverage report
# runs-on: ubuntu-latest
# needs: integration-test
# steps:
# - uses: actions/download-artifact@v3
# with:
# name: integration_coverage_report
# - uses: codecov/codecov-action@v3
# env:
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
# with:
# files: integration-test-cover.out
# flags: integrationtests
# fail_ci_if_error: true
52 changes: 52 additions & 0 deletions .github/workflows/golang_linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Go Linter

on:
push:
branches-ignore:
- main
- master
pull_request:
branches:
- main
- master
release:

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: './go.mod'

- name: Lint
uses: golangci/golangci-lint-action@v3
# continue-on-error: true
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.54.2

# Optional: working directory, useful for monorepos
# TODO: remove before release
working-directory: internal

# Optional: golangci-lint command line arguments.
args: --timeout=5m

# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true

# Optional: if set to true then the all caching functionality will be complete disabled,
# takes precedence over all other caching options.
# skip-cache: true

# Optional: if set to true then the action don't cache or restore ~/go/pkg.
# skip-pkg-cache: true

# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
# skip-build-cache: true
91 changes: 91 additions & 0 deletions .github/workflows/golang_unit_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: Go Unit Test

on:
push:
branches-ignore:
- main
- master
pull_request:
branches:
- main
- master
release:

jobs:
vet:
name: vet
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup go
uses: actions/setup-go@v4
with:
go-version-file: './go.mod'
- name: Vet
run: |
go vet ./...
fmt:
name: fmt
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup go
uses: actions/setup-go@v4
with:
go-version-file: './go.mod'
- name: fmt
run: |
go fmt ./...
unit-test:
name: unit-test
needs: ["fmt", "vet"]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup go
uses: actions/setup-go@v4
with:
go-version-file: './go.mod'

# - name: Download envtest setup script
# run: curl -sSLo setup-envtest.sh https://raw.githubusercontent.com/kubernetes-sigs/controller-runtime/master/hack/setup-envtest.sh

# - name: Make the script executable
# run: chmod +x setup-envtest.sh

# - name: Setup envtest
# run: ./setup-envtest.sh

# - name: Install Controller-gen
# run: GO111MODULE=on go get sigs.k8s.io/controller-tools/cmd/[email protected]

# - name: Install Kustomize
# run: curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash

- name: run unit tests
run: make unit-test
- uses: actions/upload-artifact@v3
with:
name: unit_coverage_report
path: unit-test-cover.out

# coverage:
# name: Coverage report
# runs-on: ubuntu-latest
# needs: unit-test
# steps:
# - uses: actions/download-artifact@v3
# with:
# name: unit_coverage_report
# - uses: codecov/codecov-action@v3
# env:
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
# with:
# files: unit-test-cover.out
# flags: unittests
# fail_ci_if_error: true
34 changes: 34 additions & 0 deletions .github/workflows/helm_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Release-Helm
on:
push:
branches:
- main
- master

jobs:
helm-release:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Install Helm
uses: azure/setup-helm@v3

- name: Run chart-releaser
uses: helm/[email protected]
with:
packages_with_index: true
mark_as_latest: false
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
44 changes: 44 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Release
on:
release:
types: [created, published]

jobs:
docker-buildx:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: appsflyer/local-pvc-releaser
tags: |
type=ref,event=tag
type=semver,pattern={{version}}
type=raw,value=latest,enable={{is_default_branch}}
- name: Validate Docker meta
run: echo "Output is empty, failing!" && exit 1
if: steps.meta.outputs.tags == ''

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/arm64,linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
7 changes: 3 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

# Image URL to use all building/pushing image targets
TAG ?= $(shell if [ -z "${CI_COMMIT_TAG}" ]; then echo "latest"; else echo ${CI_COMMIT_TAG}; fi)
IMG ?= "local-pvc-releaser"
IMG ?= "appsflyer/local-pvc-releaser"
IMAGE = "${IMG}:${TAG}"
#GIT
GIT_URL ?= "github.com/appsflyer/local-pvc-releaser"
Expand Down Expand Up @@ -74,12 +74,11 @@ lint: $(GOLINT)

.PHONY: integration-test
integration-test: generate fmt vet envtest ## Run tests.
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test ./test/... -coverprofile cover.out
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test ./test/... -coverprofile $@-cover.out -covermode atomic; go tool cover -func $@-cover.out

.PHONY: unit-test
unit-test: generate fmt vet envtest ## Run tests.
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test ./internal/... -coverprofile cover.out

KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test ./internal/... -coverprofile $@-cover.out -covermode atomic; go tool cover -func $@-cover.out
##@ Build

.PHONY: build
Expand Down
File renamed without changes.

0 comments on commit b7a4e95

Please sign in to comment.