Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jenkins 2 GH Actions Workflow Migration #362

Merged
merged 52 commits into from
Feb 13, 2023

Conversation

reakaleek
Copy link
Member

@reakaleek reakaleek commented Jan 17, 2023

Details

While migrating to GH Actions I had to utilise GoReleaser in conjunction with buildx to be able to build ARM compatible artifacts.

How to test

I ran following steps locally:

Run without pushing or publishing to AWS:

export BUILD_DATE=202301251438.25
export DOCKER_REGISTRY=fakeregistry
export DOCKER_IMAGE_NAME=test
export GORELEASER_CURRENT_TAG=v0.0.9999
go run github.com/goreleaser/goreleaser@v1.14.1 release --snapshot --rm-dist

Test aws publish script:

⚠️ You also have to export AWS_* environments for a non production account.

export BUILD_DATE=202301251120.04
export GOOS=linux
export GOARCH=arm64
export ELASTIC_LAYER_NAME=reakaleek-test 
export ARCHITECTURE=arm64
export VERSION=v0.0.9999
./.ci/publish-aws.sh

Test the GitHub release:

⚠️ But you have to modify .ci/release-github.sh and add the --draft option to the gh release command.

export VERSION=v0.0.9999
./.ci/release-github.sh

Related Issues

@github-actions github-actions bot added aws-λ-extension AWS Lambda Extension community Issues and PRs created by the community triage Issues and PRs that need to be triaged labels Jan 17, 2023
@apmmachine
Copy link

apmmachine commented Jan 17, 2023

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2023-01-24T15:57:55.255+0000

  • Duration: 7 min 22 sec

Test stats 🧪

Test Results
Failed 0
Passed 208
Skipped 2
Total 210

🤖 GitHub comments

Expand to view the GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@reakaleek reakaleek force-pushed the feature/jenkinsfile-2-gh-actions-workflow-migration branch from eaaa424 to 0f6ea0f Compare January 17, 2023 14:47
@reakaleek reakaleek force-pushed the feature/jenkinsfile-2-gh-actions-workflow-migration branch 2 times, most recently from ce148de to 39f069b Compare January 19, 2023 08:29
@reakaleek reakaleek closed this Jan 19, 2023
@reakaleek reakaleek reopened this Jan 19, 2023
@reakaleek reakaleek force-pushed the feature/jenkinsfile-2-gh-actions-workflow-migration branch from 4c96618 to fc84cb2 Compare January 24, 2023 17:38
@apmmachine
Copy link

apmmachine commented Jan 24, 2023

💔 Build Failed

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2023-01-25T12:53:25.256+0000

  • Duration: 4 min 36 sec

Steps errors 2

Expand to view the steps failures

Run smoke tests
  • Took 0 min 16 sec . View more details here
  • Description: make smoketest/run TEST_DIR=./tf
Shell Script
  • Took 0 min 0 sec . View more details here
  • Description: rm /var/lib/jenkins/workspace/aws-lambda-smoketests-mbp_PR-362/src/github.com/elastic/apm-aws-lambda@tmp/aws-credentials.json

@reakaleek
Copy link
Member Author

reakaleek commented Jan 24, 2023

@elastic/observablt-ci there seems to be a status context naming collision.
Both

are reporting the same status check.

@reakaleek reakaleek requested review from kruskall, AlexanderWert and a team January 24, 2023 18:15
@@ -0,0 +1,81 @@
project_name: apm-lambda-extension
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Migrated to GoReleaser because we don't have ARM runners available in GH Actions workflows by default.

@reakaleek reakaleek marked this pull request as ready for review January 24, 2023 18:44
Copy link
Member

@v1v v1v left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!! A few comments

Dockerfile Show resolved Hide resolved
.github/workflows/release.yml Outdated Show resolved Hide resolved
.ci/release-github.sh Show resolved Hide resolved
.ci/publish-aws.sh Outdated Show resolved Hide resolved
.ci/publish-aws.sh Outdated Show resolved Hide resolved
.goreleaser.yaml Show resolved Hide resolved
.github/workflows/release.yml Show resolved Hide resolved
.github/workflows/release.yml Outdated Show resolved Hide resolved
.github/workflows/release.yml Outdated Show resolved Hide resolved
.github/workflows/release.yml Show resolved Hide resolved
v1v added a commit that referenced this pull request Jan 24, 2023
As pointed in the below comment:
#362 (comment)
@v1v v1v mentioned this pull request Jan 24, 2023
@reakaleek reakaleek self-assigned this Jan 26, 2023
Makefile Outdated Show resolved Hide resolved
Makefile Show resolved Hide resolved
Dockerfile Outdated
@@ -3,6 +3,10 @@
# https://github.com/docker-library/repo-info/tree/master/repos/alpine/remote
FROM alpine@sha256:bc41182d7ef5ffc53a40b044e725193bc10142a1243f395ee852a8d9730fc2ad
ARG EXTENSION_FILE
ARG BUILD_DATE
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: I don't think this is right. The dockerfile is only copying the build artifacts to the docker image. There should be no need to change the file time inside the docker image as the build artifacts should have already been built reproducibly.

Copy link
Member Author

@reakaleek reakaleek Jan 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason for this way of doing it is a "limitation" of GoReleaser as it copies the artifacts and files used in the Dockerfile to a temporary directory and builds it from there. Hence any touching of the files before running the build is lost.

You can see this behavior when running make dist

image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried running the command and got the following:

release failed after 1s                  error=docker build failed: failed to build docker.elastic.co/observability/apm-lambda-extension-arm64:1.2.0: exit status 125: unknown flag: --builder

it seems goreleaser is using docker-buildx under the hood. Installing docker-buildx fixed the issues. (should be documented, opened a followup issue: #372)

building the docker image is failing but I think that's related to a typo. I've left a comment below.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I see some progress but the build is still failing:

#8 [4/4] RUN find /opt -exec touch -amdt "1675338235" {} ;
#8 0.240 exec /bin/sh: exec format error
#8 ERROR: executor failed running [/bin/sh -c find /opt -exec touch -amdt "${COMMIT_TIMESTAMP}" {} \;]: exit code: 1
------
 > [4/4] RUN find /opt -exec touch -amdt "1675338235" {} ;:
#8 0.240 exec /bin/sh: exec format error
------
ERROR: failed to solve: executor failed running [/bin/sh -c find /opt -exec touch -amdt "${COMMIT_TIMESTAMP}" {} \;]: exit code: 1

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@reakaleek I think this is the last issue. Is the docker build working for you ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. Yes, it works for me. (Apple macOS M1)

And this workflow shows that it should work with Ubuntu on amd64.

Looking at your error message, if I recall correctly, this could be a buildx setup issue.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to reproduce the issue by building the arm64 image.

docker buildx build --platform linux/arm64 .

I'm on linux (amd64). I'll investigate more

@reakaleek reakaleek force-pushed the feature/jenkinsfile-2-gh-actions-workflow-migration branch from 4a72e87 to c9ad1d7 Compare January 30, 2023 08:43
Copy link
Member

@kruskall kruskall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a minor comment

.goreleaser.yaml Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
Dockerfile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
.goreleaser.yaml Show resolved Hide resolved
Dockerfile Outdated Show resolved Hide resolved
Dockerfile Outdated Show resolved Hide resolved
reakaleek and others added 2 commits February 13, 2023 09:36
Co-authored-by: kruskall <99559985+kruskall@users.noreply.github.com>
Co-authored-by: kruskall <99559985+kruskall@users.noreply.github.com>
Copy link
Member

@kruskall kruskall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@reakaleek reakaleek merged commit df1ba5e into main Feb 13, 2023
@reakaleek reakaleek deleted the feature/jenkinsfile-2-gh-actions-workflow-migration branch February 13, 2023 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aws-λ-extension AWS Lambda Extension community Issues and PRs created by the community triage Issues and PRs that need to be triaged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants