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

Trent/image ci #25

Merged
merged 17 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/test-api-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Test API Image CI

on:
pull_request:
paths:
- integration-tests/test-api/**

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true


jobs:
build:
trent-codecov marked this conversation as resolved.
Show resolved Hide resolved
name: Build API Test
trent-codecov marked this conversation as resolved.
Show resolved Hide resolved
uses: codecov/gha-workflows/.github/workflows/[email protected]
trent-codecov marked this conversation as resolved.
Show resolved Hide resolved
secrets: inherit
trent-codecov marked this conversation as resolved.
Show resolved Hide resolved
with:
push: false
image_name: codecov-javascript-bundler-plugins-test-api
docker_path: integration-tests/test-api
24 changes: 24 additions & 0 deletions .github/workflows/test-api-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Test API Image Push

on:
push:
branches:
- main
paths:
- integration-tests/test-api/**

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true


jobs:
push:
name: Push API Test
if: github.repository_owner == 'codecov'
uses: codecov/gha-workflows/.github/workflows/[email protected]
Copy link

@codecov codecov bot Dec 9, 2023

Choose a reason for hiding this comment

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

Like in the above file, the 'secrets' keyword does not seem to be used correctly. Secrets can be accessed using the secrets context but need to be passed to the env attribute.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@eliatcodecov The bot is getting snarky

secrets: inherit
with:
push: true
trent-codecov marked this conversation as resolved.
Show resolved Hide resolved
image_name: codecov-javascript-bundler-plugins-test-api
docker_path: integration-tests/test-api
31 changes: 31 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
DOCKERHUB_REPO ?= codecov
IMAGE_NAME ?= codecov-javascript-bundler-plugins-test-api
trent-codecov marked this conversation as resolved.
Show resolved Hide resolved
DOCKER_PATH ?= integration-tests/test-api
trent-codecov marked this conversation as resolved.
Show resolved Hide resolved
OS_NAME := $(shell uname -s | tr A-Z a-z)
BUILD_PLATFORM :=
ifeq ($(OS_NAME),darwin)
BUILD_PLATFORM := arm64
Copy link

@codecov codecov bot Dec 9, 2023

Choose a reason for hiding this comment

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

The BUILD_PLATFORM is being set to 'arm64' for Darwin systems. However, not all Darwin systems are arm64, some are x86_64 (Intel). Consider a more comprehensive approach to accurately determine the architecture.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@eliatcodecov this is actually a really good one

else
trent-codecov marked this conversation as resolved.
Show resolved Hide resolved
BUILD_PLATFORM := linux/amd64
trent-codecov marked this conversation as resolved.
Show resolved Hide resolved
endif
sha := $(shell git rev-parse --short=7 HEAD)
dockerhub_image := ${DOCKERHUB_REPO}/${IMAGE_NAME}
export DOCKER_BUILDKIT := 1

build.${IMAGE_NAME}:
docker build -f ${DOCKER_PATH}/Dockerfile ${DOCKER_PATH} -t ${dockerhub_image}:latest \
trent-codecov marked this conversation as resolved.
Show resolved Hide resolved
-t ${dockerhub_image}:${sha} \
trent-codecov marked this conversation as resolved.
Show resolved Hide resolved
--label "org.label-schema.build-date"="$(build_date)" \
trent-codecov marked this conversation as resolved.
Show resolved Hide resolved
--label "org.label-schema.name"="${IMAGE_NAME}" \
trent-codecov marked this conversation as resolved.
Show resolved Hide resolved
--label "org.label-schema.vendor"="Codecov" \
trent-codecov marked this conversation as resolved.
Show resolved Hide resolved
--label "org.label-schema.version"="${sha}" \
--build-arg BUILDPLATFORM=${BUILD_PLATFORM}

tag.${IMAGE_NAME}:
trent-codecov marked this conversation as resolved.
Show resolved Hide resolved
docker tag ${dockerhub_image}:${sha} ${dockerhub_image}:latest

push.${IMAGE_NAME}:
docker push ${dockerhub_image}:latest
trent-codecov marked this conversation as resolved.
Show resolved Hide resolved

save.${IMAGE_NAME}:
docker save -o ${IMAGE_NAME}.tar ${dockerhub_image}:${sha}
4 changes: 3 additions & 1 deletion integration-tests/test-api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM --platform=arm64 node:20-alpine
trent-codecov marked this conversation as resolved.
Show resolved Hide resolved
# syntax=docker/dockerfile:1
ARG BUILDPLATFORM=arm64
trent-codecov marked this conversation as resolved.
Show resolved Hide resolved
FROM --platform=$BUILDPLATFORM node:20-alpine
trent-codecov marked this conversation as resolved.
Show resolved Hide resolved
WORKDIR /app

ENV NODE_ENV=production
Expand Down