Skip to content

Commit

Permalink
Merge pull request #83 from zapier/fix-deploys-upgrade-earthly
Browse files Browse the repository at this point in the history
fix deploys, upgrade earthly
  • Loading branch information
djeebus authored Mar 13, 2024
2 parents 27b0fd3 + e343139 commit cf66e73
Show file tree
Hide file tree
Showing 12 changed files with 97 additions and 55 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
!go.mod
!go.sum
!*.go
dist
6 changes: 5 additions & 1 deletion .github/workflows/on_merge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@ jobs:
with: { version: "v${{ env.EARTHLY_TOOL_VERSION }}" }

- name: run continuous deployment actions
run: earthly --push +continuous-deploy --token ${{ secrets.GITHUB_TOKEN }}
run: |
./earthly \
--push \
+continuous-deploy \
--token ${{ secrets.GITHUB_TOKEN }}
11 changes: 8 additions & 3 deletions .github/workflows/on_pull_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:


jobs:
build:
build-image:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
Expand All @@ -22,7 +22,12 @@ jobs:
- uses: earthly/actions-setup@v1
with: { version: "v${{ env.EARTHLY_TOOL_VERSION }}" }

- run: earthly +build --GOLANG_VERSION=${{ env.GOLANG_TOOL_VERSION }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

# intentionally avoiding --push, this is just
# to test the command
- run: ./earthly +build-image-multiarch

release-test:
runs-on: ubuntu-22.04
Expand All @@ -36,7 +41,7 @@ jobs:

# intentionally avoiding --push, this is just
# to test the command
- run: earthly +release --GOLANG_VERSION=${{ env.GOLANG_TOOL_VERSION }}
- run: ./earthly +release-binaries

skaffold:
runs-on: ubuntu-22.04
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/on_pull_request_go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ jobs:
- uses: earthly/actions-setup@v1
with: { version: "v${{ env.EARTHLY_TOOL_VERSION }}" }

- run: earthly +ci-golang --GOLANG_VERSION=${{ env.GOLANG_TOOL_VERSION }}
- run: ./earthly +ci-golang
2 changes: 1 addition & 1 deletion .github/workflows/on_pull_request_helm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
- uses: earthly/actions-setup@v1
with: { version: "v${{ env.EARTHLY_TOOL_VERSION }}" }

- run: earthly +ci-helm
- run: ./earthly +ci-helm
16 changes: 8 additions & 8 deletions .github/workflows/on_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ jobs:

- name: Build and push the binaries
run: |
earthly \
./earthly \
--push \
+release-binaries \
--version=${{ env.RELEASE_VERSION }} \
--commitSHA=${{ env.SHORT_SHA }} \
--token ${{ secrets.GITHUB_TOKEN }}
--version=${{ env.RELEASE_VERSION }} \
--commitSHA=${{ env.SHORT_SHA }} \
--token ${{ secrets.GITHUB_TOKEN }}
release-image:
runs-on: ubuntu-22.04
Expand Down Expand Up @@ -67,9 +67,9 @@ jobs:

- name: Build and push the Docker image
run: |
earthly \
./earthly \
--push \
+build-image-multiarch \
--version=${{ env.RELEASE_VERSION }} \
--commitSHA=${{ env.SHORT_SHA }} \
--image_name=ghcr.io/${{ github.repository_owner }}/prom-aggregation-gateway
--version=${{ env.RELEASE_VERSION }} \
--commitSHA=${{ env.SHORT_SHA }} \
--image_name=ghcr.io/${{ github.repository_owner }}/prom-aggregation-gateway
11 changes: 8 additions & 3 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# asdf plugin add earthly https://github.com/YR-ZR0/asdf-earthly
earthly 0.6.30
earthly 0.8.5
github-cli 2.36.0
golang 1.21.3
skaffold 2.0.3
helm-cr 1.4.1
helm-ct 3.7.1
kubeconform 0.5.0
minikube 1.32.0
skaffold 2.10.1
staticcheck 2023.1.6
21 changes: 0 additions & 21 deletions Dockerfile

This file was deleted.

34 changes: 18 additions & 16 deletions Earthfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
VERSION 0.6
VERSION 0.8

ARG image_name="prom-aggregation-gateway"
ARG token=""
ARG --global token=""

ARG commitSHA=""
ARG version="dev"
ARG PKG_PATH="github.com/zapier/prom-aggregation-gateway"
ARG --global commitSHA=""
ARG --global version="dev"
ARG --global PKG_PATH="github.com/zapier/prom-aggregation-gateway"

ARG ALPINE_VERSION="3.18.4"
ARG GOLANG_ALPINE_VERSION="3.18"
ARG CHART_RELEASER_VERSION="1.4.1"
ARG CHART_TESTING_VERSION="3.7.1"
ARG GITHUB_CLI_VERSION="2.36.0"
ARG GOLANG_VERSION="1.21.3"
ARG HELM_UNITTEST_VERSION="0.2.8"
ARG KUBECONFORM_VERSION="0.5.0"
ARG STATICCHECK_VERSION="2023.1.6"
ARG --global ALPINE_VERSION="3.18"
ARG --global --required GOLANG_VERSION

test:
BUILD +ci-golang
Expand All @@ -40,7 +32,7 @@ release:
BUILD +build-image

go-deps:
FROM golang:${GOLANG_VERSION}-alpine${GOLANG_ALPINE_VERSION}
FROM golang:${GOLANG_VERSION}-alpine${ALPINE_VERSION}

WORKDIR /src
COPY go.mod go.sum /src
Expand All @@ -64,6 +56,8 @@ build-image:
ENV GIN_MODE=release
USER 65534
ENTRYPOINT ["/prom-aggregation-gateway"]

ARG image_name="prom-aggregation-gateway"
SAVE IMAGE --push ${image_name}:${version}
SAVE IMAGE --push ${image_name}:latest

Expand Down Expand Up @@ -104,6 +98,7 @@ release-binaries:
COPY +build-binaries/_dist dist

# install github cli
ARG --required GITHUB_CLI_VERSION
RUN FILE=ghcli.tgz \
&& URL=https://github.com/cli/cli/releases/download/v${GITHUB_CLI_VERSION}/gh_${GITHUB_CLI_VERSION}_linux_amd64.tar.gz \
&& wget ${URL} \
Expand All @@ -125,6 +120,7 @@ lint-golang:
FROM +go-deps

# install staticcheck
ARG --required STATICCHECK_VERSION
RUN FILE=staticcheck.tgz \
&& URL=https://github.com/dominikh/go-tools/releases/download/${STATICCHECK_VERSION}/staticcheck_linux_amd64.tar.gz \
&& wget ${URL} \
Expand All @@ -150,9 +146,12 @@ test-golang:
RUN go test .

test-helm:
ARG --required CHART_TESTING_VERSION

FROM quay.io/helmpack/chart-testing:v${CHART_TESTING_VERSION}

# install kubeconform
ARG --required KUBECONFORM_VERSION
RUN FILE=kubeconform.tgz \
&& URL=https://github.com/yannh/kubeconform/releases/download/v${KUBECONFORM_VERSION}/kubeconform-linux-amd64.tar.gz \
&& wget ${URL} \
Expand All @@ -164,6 +163,7 @@ test-helm:
--file ${FILE} \
&& kubeconform -v

ARG HELM_UNITTEST_VERSION="0.2.8"
RUN apk add --no-cache bash git \
&& helm plugin install --version "${HELM_UNITTEST_VERSION}" https://github.com/quintush/helm-unittest \
&& helm unittest --help
Expand All @@ -175,6 +175,8 @@ test-helm:
RUN ct --config ./.github/ct.yaml lint ./charts

build-helm:
ARG --required CHART_RELEASER_VERSION

FROM quay.io/helmpack/chart-releaser:v${CHART_RELEASER_VERSION}

ARG token
Expand Down
39 changes: 39 additions & 0 deletions earthly
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env bash

to_echo() {
if [ "$1" -eq 1 ]; then
echo "$2"
fi
}

read_tool_versions_write_to_env() {
local -r tool_versions_file="$1"

# loop over each line of the .tool-versions file
while read -r line; do
# split the line into a bash array using the default space delimeter
IFS=" " read -r -a lineArray <<<"$line"

# get the key and value from the array, set the key to all uppercase
key="${lineArray[0],,}"
value="${lineArray[1]}"

# ignore comments, comments always start with #
if [[ ${key:0:1} != "#" ]]; then
full_key="${key/-/_}_tool_version"
export "${full_key}=${value}"
fi
done <"$tool_versions_file"
}

read_tool_versions_write_to_env '.tool-versions'

set -x

earthly $* \
--CHART_RELEASER_VERSION=${helm_cr_tool_version} \
--CHART_TESTING_VERSION=${helm_ct_tool_version} \
--GITHUB_CLI_VERSION=${github_cli_tool_version} \
--GOLANG_VERSION=${golang_tool_version} \
--KUBECONFORM_VERSION=${kubeconform_tool_version} \
--STATICCHECK_VERSION=${staticcheck_tool_version}
7 changes: 7 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
minikube-up:
minikube start
minikube addons enable ingress
minikube addons enable registryi

minikube-reset:
minikube delete --all
2 changes: 1 addition & 1 deletion skaffold.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ build:
artifacts:
- image: prom-aggregation-gateway
custom:
buildCommand: earthly +build-image --version=$IMAGE_TAG --image_name=$IMAGE_REPO
buildCommand: EARTHLY_DISABLE_REMOTE_REGISTRY_PROXY=true ./earthly +build-image --version=$IMAGE_TAG --image_name=$IMAGE_REPO --no-satellite
tagPolicy:
customTemplate:
template: dev
Expand Down

0 comments on commit cf66e73

Please sign in to comment.