Skip to content

Commit 2fb1c5f

Browse files
authored
Merge pull request #60 from segmentio/fix-ci
Move CI to buildkite and fix
2 parents 60dafb8 + 867f757 commit 2fb1c5f

File tree

7 files changed

+76
-88
lines changed

7 files changed

+76
-88
lines changed

.buildkite/pipeline.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
steps:
2+
- label: Install dependencies
3+
env:
4+
SEGMENT_BUILDKITE_IMAGE: "buildkite-agent-golang1.19:latest"
5+
SEGMENT_CONTEXTS: 'snyk'
6+
agents:
7+
queue: v1
8+
commands: |
9+
which -a go
10+
env | grep PATH
11+
export PATH=$PATH:/go/bin:/var/lib/buildkite-agent/go/bin:/go/src/github.com/segmentio/kubeapply/deps:$HOME/local/bin
12+
mkdir -p deps
13+
cd deps && ../scripts/pull-deps.sh && cd -
14+
env | grep PATH
15+
ls -al "${HOME}/local/bin"
16+
which -a helm
17+
SNYK_LEVEL=FLHI curl -sL https://raw.githubusercontent.com/segmentio/snyk_helpers/master/initialization/snyk.sh | sh
18+
19+
- label: 'Publish'
20+
env:
21+
SEGMENT_CONTEXTS: "aws-credentials,ecr"
22+
SEGMENT_BUILDKITE_IMAGE: 'buildkite-agent-golang1.19:latest'
23+
agents:
24+
queue: v1
25+
commands: |
26+
export PATH=$PATH:/go/bin:/var/lib/buildkite-agent/go/bin:/go/src/github.com/segmentio/kubeapply/deps:$HOME/local/bin
27+
make publish

.circleci/config.yml

Lines changed: 0 additions & 83 deletions
This file was deleted.

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Fetch or build all required binaries
2-
FROM golang:1.18 as builder
2+
FROM golang:1.19 as builder
33

44
ARG VERSION_REF
55
RUN test -n "${VERSION_REF}"
@@ -8,6 +8,7 @@ ENV SRC github.com/segmentio/kubeapply
88

99
RUN apt-get update && apt-get install --yes \
1010
curl \
11+
unzip \
1112
wget
1213

1314
COPY . /go/src/${SRC}

Dockerfile.lambda

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Fetch or build all required binaries
2-
FROM golang:1.18 as builder
2+
FROM golang:1.19 as builder
33

44
ARG VERSION_REF
55
RUN test -n "${VERSION_REF}"
@@ -8,6 +8,7 @@ ENV SRC github.com/segmentio/kubeapply
88

99
RUN apt-get update && apt-get install --yes \
1010
curl \
11+
unzip \
1112
wget
1213

1314
COPY . /go/src/${SRC}
@@ -26,7 +27,8 @@ RUN make kubeapply-lambda VERSION_REF=${VERSION_REF} && \
2627
# Copy into final image
2728
FROM public.ecr.aws/lambda/go:1
2829

29-
RUN yum install -y git
30+
RUN yum install -y git && \
31+
python3 --version
3032

3133
RUN curl -O https://bootstrap.pypa.io/pip/3.6/get-pip.py && python3 get-pip.py
3234
RUN pip3 install awscli

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,6 @@ endif
7878
.PHONY: clean
7979
clean:
8080
rm -Rf *.zip .kube build vendor
81+
82+
publish:
83+
./scripts/publish.sh

scripts/publish.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
AWS_ACCOUNT_ID='528451384384'
6+
AWS_REGION='us-west-2'
7+
8+
main() {
9+
local -r SHORT_GIT_SHA=$(git rev-parse --short HEAD)
10+
local -r image="${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com/kubeapply:${SHORT_GIT_SHA}"
11+
local -r lambda_image="${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com/kubeapply-lambda:${SHORT_GIT_SHA}"
12+
docker build \
13+
-t "${image}" \
14+
--build-arg VERSION_REF="${SHORT_GIT_SHA}" \
15+
.
16+
docker push "${image}"
17+
18+
docker build \
19+
-f Dockerfile.lambda \
20+
-t "${lambda_image}" \
21+
--build-arg VERSION_REF="${SHORT_GIT_SHA}" \
22+
.
23+
docker push "${lambda_image}"
24+
}
25+
26+
main "$@"

scripts/pull-deps.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/bin/bash
22

3-
set -e
3+
set -euo pipefail
4+
5+
# Note this is used by both the publish script and the test script.
46

57
# Required versions
68

@@ -23,11 +25,15 @@ KIND_SHA_256_SUM="781c3db479b805d161b7c2c7a31896d1a504b583ebfcce8fcd49538c684d96
2325
GOOS=linux
2426
GOARCH=amd64
2527

28+
mkdir -p "${HOME}/local/bin"
29+
2630
echo "Downloading helm at version ${HELM_VERSION}"
2731
wget -q https://get.helm.sh/helm-v${HELM_VERSION}-${GOOS}-${GOARCH}.tar.gz
2832
echo "${HELM_SHA256_SUM} helm-v${HELM_VERSION}-${GOOS}-${GOARCH}.tar.gz" | sha256sum -c
2933
tar -xzf helm-v${HELM_VERSION}-${GOOS}-${GOARCH}.tar.gz
30-
cp ${GOOS}-${GOARCH}/helm .
34+
${GOOS}-${GOARCH}/helm version
35+
# try /usr/local/bin (for Dockerfile) and fall back
36+
cp ${GOOS}-${GOARCH}/helm "/usr/local/bin" || cp ${GOOS}-${GOARCH}/helm "${HOME}/local/bin"
3137

3238
echo "Downloading aws-iam-authenticator at version ${IAM_AUTHENTICATOR_VERSION}"
3339
wget -q -O aws-iam-authenticator https://github.com/kubernetes-sigs/aws-iam-authenticator/releases/download/v${IAM_AUTHENTICATOR_VERSION}/aws-iam-authenticator_${IAM_AUTHENTICATOR_VERSION}_${GOOS}_${GOARCH}
@@ -44,3 +50,9 @@ echo "Downloading kind at version ${KIND_VERSION}"
4450
wget -q -O kind https://kind.sigs.k8s.io/dl/${KIND_VERSION}/kind-${GOOS}-${GOARCH}
4551
echo "${KIND_SHA_256_SUM} kind" | sha256sum -c
4652
chmod +x kind
53+
54+
# https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html
55+
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
56+
unzip -q awscliv2.zip
57+
mkdir -p "${HOME}/local/aws"
58+
./aws/install --install-dir "${HOME}/local/aws" --bin-dir "${HOME}/local/bin"

0 commit comments

Comments
 (0)