1
0
Fork 0
mirror of https://github.com/external-secrets/external-secrets.git synced 2024-12-14 11:57:59 +00:00

Merge pull request #11 from external-secrets/feat/basic-ci

Basic CI
This commit is contained in:
Lucas Severo Alves 2020-12-11 19:15:26 +01:00 committed by GitHub
commit d10ce31973
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 237 additions and 0 deletions

13
.github/issue_template.md vendored Normal file
View file

@ -0,0 +1,13 @@
**Describe the solution you'd like**
Describe the end goal of this proposal. What is this new functionality or the new behaviour (or what problem does it fix)?
**What is the added value?**
Explain the value that it adds. e.g. "Secret refreshing will make internal secrets up to date with external secrets".
**Give us examples of the outcome**
Provide templates if you are proposing changes in the CRD. Provide example workflows or code snippets if they make sense to present.
**Observations (Constraints, Context, etc):**
Give here all extra information that could be interesting. Such as Golang version and Kubernetes version if you are reporting a bug/problem. You can also foresee technical constrains like "this could only be implementing using this specific technology or approach, because of this and that".

74
.github/workflows/all.yml vendored Normal file
View file

@ -0,0 +1,74 @@
name: all-ci
on:
push:
branches:
- '*' # matches every branch that doesn't contain a '/'
- '*/*' # matches every branch containing a single '/'
- '**' # matches every branch
- '!main' # excludes main
pull_request:
branches: [ '!main' ]
env:
KUBEBUILDER_VERSION: 2.3.1
jobs:
build:
name: Build
container:
image: golang:1.15
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Get dependencies
run: |
go get -v -t -d ./...
- name: Add kubebuilder
run: |
curl -L https://github.com/kubernetes-sigs/kubebuilder/releases/download/v${{env.KUBEBUILDER_VERSION}}/kubebuilder_${{env.KUBEBUILDER_VERSION}}_linux_amd64.tar.gz > kubebuilder_${{env.KUBEBUILDER_VERSION}}_linux_amd64.tar.gz
tar -xvf kubebuilder_${{env.KUBEBUILDER_VERSION}}_linux_amd64.tar.gz
mv kubebuilder_${{env.KUBEBUILDER_VERSION}}_linux_amd64 /usr/local/kubebuilder
- name: Vet and Build
run: make manager
test:
name: Test
container:
image: golang:1.15
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Get dependencies
run: |
go get -v -t -d ./...
- name: Add kubebuilder
run: |
curl -L https://github.com/kubernetes-sigs/kubebuilder/releases/download/v${{env.KUBEBUILDER_VERSION}}/kubebuilder_${{env.KUBEBUILDER_VERSION}}_linux_amd64.tar.gz > kubebuilder_${{env.KUBEBUILDER_VERSION}}_linux_amd64.tar.gz
tar -xvf kubebuilder_${{env.KUBEBUILDER_VERSION}}_linux_amd64.tar.gz
mv kubebuilder_${{env.KUBEBUILDER_VERSION}}_linux_amd64 /usr/local/kubebuilder
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Test
run: make test
- name: Coverage
uses: codecov/codecov-action@v1
with:
# token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
file: ./cover.out
# flags: unittests # optional
name: external-secrets
fail_ci_if_error: false

150
.github/workflows/main.yml vendored Normal file
View file

@ -0,0 +1,150 @@
name: main-ci
on:
push:
branches: [ main ]
tags:
- '*'
pull_request:
branches: [ main ]
env:
KUBEBUILDER_VERSION: 2.3.1
jobs:
build:
name: Build
container:
image: golang:1.15
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Get dependencies
run: |
go get -v -t -d ./...
- name: Add kubebuilder
run: |
curl -L https://github.com/kubernetes-sigs/kubebuilder/releases/download/v${{env.KUBEBUILDER_VERSION}}/kubebuilder_${{env.KUBEBUILDER_VERSION}}_linux_amd64.tar.gz > kubebuilder_${{env.KUBEBUILDER_VERSION}}_linux_amd64.tar.gz
tar -xvf kubebuilder_${{env.KUBEBUILDER_VERSION}}_linux_amd64.tar.gz
mv kubebuilder_${{env.KUBEBUILDER_VERSION}}_linux_amd64 /usr/local/kubebuilder
- name: Vet and Build
run: make manager
test:
name: Test
container:
image: golang:1.15
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Get dependencies
run: |
go get -v -t -d ./...
- name: Add kubebuilder
run: |
curl -L https://github.com/kubernetes-sigs/kubebuilder/releases/download/v${{env.KUBEBUILDER_VERSION}}/kubebuilder_${{env.KUBEBUILDER_VERSION}}_linux_amd64.tar.gz > kubebuilder_${{env.KUBEBUILDER_VERSION}}_linux_amd64.tar.gz
tar -xvf kubebuilder_${{env.KUBEBUILDER_VERSION}}_linux_amd64.tar.gz
mv kubebuilder_${{env.KUBEBUILDER_VERSION}}_linux_amd64 /usr/local/kubebuilder
- name: Test
run: make test
- name: Coverage
uses: codecov/codecov-action@v1
with:
# token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
file: ./cover.out
# flags: unittests # optional
name: external-secrets
fail_ci_if_error: true
docker:
name: Docker
runs-on: ubuntu-latest
needs: [build, test]
steps:
- name: Prepare
id: prep
run: |
DOCKER_IMAGE=ghcr.io/external-secrets/external-secrets
VERSION=edge
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
elif [[ $GITHUB_REF == refs/heads/* ]]; then
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
elif [[ $GITHUB_REF == refs/pull/* ]]; then
VERSION=pr-${{ github.event.number }}
fi
TAGS="${DOCKER_IMAGE}:${VERSION}"
if [ "${{ github.event_name }}" = "push" ]; then
TAGS="$TAGS,${DOCKER_IMAGE}:sha-${GITHUB_SHA::8}"
fi
PUSH_IMAGE=true
REPO_FULL_NAME="${{ github.event.pull_request.head.repo.full_name }}"
# If this is both a pull request and a fork, then don't push the image
if [[ ${{ github.event_name }} == pull_request ]]; then
if [[ $REPO_FULL_NAME != external-secrets/external-secrets ]]; then
PUSH_IMAGE=false
fi
fi
REPO_URL=https://github.com/${{github.repository}}
echo ::set-output name=version::${VERSION}
echo ::set-output name=tags::${TAGS}
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
echo ::set-output name=push_image::$PUSH_IMAGE
echo ::set-output name=repo_url::$REPO_URL
- name: Check out the repo
uses: actions/checkout@v2
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v1
with:
platforms: linux/amd64
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Login to Github Packages
id: docker-login
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ secrets.GHCR_USERNAME }}
password: ${{ secrets.GHCR_TOKEN }}
if: ${{ steps.prep.outputs.push_image == 'true' }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
builder: ${{ steps.buildx.outputs.name }}
platforms: linux/amd64
tags: ${{ steps.prep.outputs.tags }}
push: ${{ steps.prep.outputs.push_image }}
labels: |
org.opencontainers.image.source=${{ steps.prep.outputs.repo_url }}
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.revision=${{ github.sha }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}