Skip to content
This repository has been archived by the owner on Jul 30, 2024. It is now read-only.

Commit

Permalink
BUILD: WORKING COMMIT - DELETE
Browse files Browse the repository at this point in the history
  • Loading branch information
DeveloperC286 committed Dec 20, 2023
1 parent 5329ac4 commit 6c97a10
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 44 deletions.
18 changes: 4 additions & 14 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,26 +67,16 @@ jobs:
uses: actions/checkout@v3
- name: Check modules.
run: earthly --ci +check-modules
compile-darwin-amd64:
name: Compile Darwin AMD64
compile:
name: Compile
runs-on: ubuntu-latest
steps:
- name: Download Earthly v0.7.17.
run: "sudo /bin/sh -c 'wget https://github.com/earthly/earthly/releases/download/v0.7.17/earthly-linux-amd64 -O /usr/local/bin/earthly && chmod +x /usr/local/bin/earthly'"
- name: Checkout code.
uses: actions/checkout@v3
- name: Compile Darwin AMD64.
run: earthly --ci +compile-darwin-amd64
compile-linux-amd64:
name: Compile Linux AMD64
runs-on: ubuntu-latest
steps:
- name: Download Earthly v0.7.17.
run: "sudo /bin/sh -c 'wget https://github.com/earthly/earthly/releases/download/v0.7.17/earthly-linux-amd64 -O /usr/local/bin/earthly && chmod +x /usr/local/bin/earthly'"
- name: Checkout code.
uses: actions/checkout@v3
- name: Compile Linux AMD64.
run: earthly --ci +compile-linux-amd64
- name: Compile.
run: earthly --ci +compile
unit-test:
name: Unit Test
runs-on: ubuntu-latest
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@

# Generated by Go coverage.
*.out

# Generated by GoReleaser.
dist/
11 changes: 11 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 1

builds:
- id: starling-bank-technical-challenge
main: ./cmd/starling-bank-technical-challenge
env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
65 changes: 39 additions & 26 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ COPY_CI_DATA:
COMMAND
COPY "./ci" "./ci"
COPY ".github" ".github"
COPY ".goreleaser.yaml" ".goreleaser.yaml"


COPY_METADATA:
Expand Down Expand Up @@ -56,12 +57,6 @@ COPY_SOURCECODE:
COPY "./api" "./api"


SAVE_OUTPUT:
COMMAND
SAVE ARTIFACT "starling-bank-technical-challenge" AS LOCAL "starling-bank-technical-challenge"
SAVE ARTIFACT "go.sum" AS LOCAL "go.sum"


golang-base:
FROM golang:1.20.4
WORKDIR /tmp/starling-bank-technical-challenge
Expand All @@ -80,7 +75,7 @@ check-go-formatting:

sh-formatting-base:
FROM golang
RUN go install mvdan.cc/sh/v3/cmd/[email protected]
RUN go install mvdan.cc/sh/v3/cmd/[email protected]
DO +COPY_CI_DATA


Expand All @@ -91,7 +86,7 @@ check-shell-formatting:

yaml-formatting-base:
FROM golang
RUN go install github.com/google/yamlfmt/cmd/[email protected]
RUN go install github.com/google/yamlfmt/cmd/[email protected]
COPY ".yamlfmt" ".yamlfmt"
DO +COPY_CI_DATA

Expand Down Expand Up @@ -183,21 +178,22 @@ fix-modules:
SAVE ARTIFACT "go.sum" AS LOCAL "go.sum"


compile-linux-amd64:
FROM +golang-base
DO +INSTALL_DEPENDENCIES
DO +COPY_SOURCECODE
RUN ./ci/compile.sh
DO +SAVE_OUTPUT
INSTALL_GORELEASER:
COMMAND
ENV GORELEASER_VERSION=1.22.1
RUN wget "https://github.com/goreleaser/goreleaser/releases/download/v${GORELEASER_VERSION}/goreleaser_Linux_x86_64.tar.gz"
RUN tar -xzvf "goreleaser_Linux_x86_64.tar.gz"
RUN cp "goreleaser" /bin/goreleaser


compile-darwin-amd64:
compile:
FROM +golang-base
ENV GOOS=darwin
DO +INSTALL_GORELEASER
DO +INSTALL_DEPENDENCIES
DO +COPY_SOURCECODE
RUN ./ci/compile.sh
DO +SAVE_OUTPUT
SAVE ARTIFACT "dist" AS LOCAL "dist"
SAVE ARTIFACT "go.sum" AS LOCAL "go.sum"


unit-test:
Expand All @@ -207,18 +203,35 @@ unit-test:
RUN ./ci/unit-test.sh


release:
FROM +ubuntu-base
RUN apt-get install wget git -y
# Install GitHub CLI.
ENV GH_VERSION=2.30.0
RUN wget "https://github.com/cli/cli/releases/download/v${GH_VERSION}/gh_${GH_VERSION}_linux_amd64.tar.gz"
RUN tar -xzvf "gh_${GH_VERSION}_linux_amd64.tar.gz"
RUN cp "./gh_${GH_VERSION}_linux_amd64/bin/gh" /bin/gh
# Install Git Cliff.
INSTALL_GITHUB_CLI:
COMMAND
ENV GITHUB_CLI_VERSION=2.30.0
RUN wget "https://github.com/cli/cli/releases/download/v${GITHUB_CLI_VERSION}/gh_${GITHUB_CLI_VERSION}_linux_amd64.tar.gz"
RUN tar -xzvf "gh_${GITHUB_CLI_VERSION}_linux_amd64.tar.gz"
RUN cp "./gh_${GITHUB_CLI_VERSION}_linux_amd64/bin/gh" /bin/gh


INSTALL_GIT_CLIFF:
COMMAND
ENV GIT_CLIFF_VERSION=1.2.0
RUN wget "https://github.com/orhun/git-cliff/releases/download/v${GIT_CLIFF_VERSION}/git-cliff-${GIT_CLIFF_VERSION}-x86_64-unknown-linux-gnu.tar.gz"
RUN tar -xzvf "git-cliff-${GIT_CLIFF_VERSION}-x86_64-unknown-linux-gnu.tar.gz"
RUN cp "./git-cliff-${GIT_CLIFF_VERSION}/git-cliff" /bin/git-cliff


release:
FROM +ubuntu-base
RUN apt-get install wget git -y
DO +INSTALL_GITHUB_CLI
DO +INSTALL_GIT_CLIFF
DO +COPY_METADATA
RUN --secret GH_TOKEN ./ci/release.sh


release-artifacts:
FROM +ubuntu-base
RUN apt-get install wget jq -y
DO +INSTALL_GITHUB_CLI
COPY +compile/dist ./dist
DO +COPY_CI_DATA
RUN --secret GH_TOKEN ./ci/release-artifacts.sh
4 changes: 2 additions & 2 deletions ci/check-yaml-formatting.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
#!/usr/bin/env sh

set -o errexit
set -o xtrace

yamlfmt -lint -dstar .github/**/*
yamlfmt -lint -dstar .github/**/* .goreleaser.yaml
2 changes: 1 addition & 1 deletion ci/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
set -o errexit
set -o xtrace

go build "./cmd/starling-bank-technical-challenge"
goreleaser build --snapshot --clean
2 changes: 1 addition & 1 deletion ci/fix-yaml-formatting.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
set -o errexit
set -o xtrace

yamlfmt -dstar ./github/**/*
yamlfmt -dstar ./github/**/* .goreleaser.yaml
11 changes: 11 additions & 0 deletions ci/release-artifacts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env sh

set -o errexit
set -o xtrace

for row in $(jq -c '.[]' "dist/artifacts.json"); do
path=$(echo "${row}" | jq -r '.path')
name=$(echo "${path}" | cut -d '/' -f 2)

echo "gh release upload TAG ${path}%#%${name}"
done

0 comments on commit 6c97a10

Please sign in to comment.