Skip to content

Commit

Permalink
CI consolidate (#2295)
Browse files Browse the repository at this point in the history
* CI consolidate

* CI consolidate

* Adding some more bun

* Adding some more bun
  • Loading branch information
trent-codecov authored Oct 3, 2023
1 parent f70b85c commit e5adcc5
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 155 deletions.
98 changes: 23 additions & 75 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ name: Gazebo CI

on:
push:
tags:
- self-hosted-*
branches:
- main
- staging
Expand Down Expand Up @@ -107,47 +105,6 @@ jobs:
run: |
npm run type-check
codecovstartup:
name: Codecov Startup
needs: install
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Install CLI
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
run: |
pip install --no-cache-dir codecov-cli
- name: Run Startup
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }}
run: |
codecovcli create-commit --fail-on-error
codecovcli create-report --fail-on-error
- name: Run Startup Staging
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
run: |
codecovcli -u ${{ secrets.CODECOV_STAGING_URL }} create-commit -t ${{ secrets.CODECOV_ORG_TOKEN_STAGING }} --fail-on-error
codecovcli -u ${{ secrets.CODECOV_STAGING_URL }} create-report -t ${{ secrets.CODECOV_ORG_TOKEN_STAGING }} --fail-on-error
- name: Run Startup QA
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
run: |
codecovcli -u ${{ secrets.CODECOV_QA_URL }} create-commit -t ${{ secrets.CODECOV_QA_TOKEN }} --fail-on-error
codecovcli -u ${{ secrets.CODECOV_QA_URL }} create-report -t ${{ secrets.CODECOV_QA_TOKEN }} --fail-on-error
- name: Run Startup Public QA
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
run: |
codecovcli -u ${{ secrets.CODECOV_PUBLIC_QA_URL }} create-commit -t ${{ secrets.CODECOV_PUBLIC_QA_TOKEN }} --fail-on-error
codecovcli -u ${{ secrets.CODECOV_PUBLIC_QA_URL }} create-report -t ${{ secrets.CODECOV_PUBLIC_QA_TOKEN }} --fail-on-error
runner-indexes:
runs-on: ubuntu-latest
name: Generate runner indexes
Expand All @@ -165,7 +122,7 @@ jobs:
test:
name: 'Test Runner #${{ matrix.runner-index }}'
needs: [install, codecovstartup, runner-indexes]
needs: [install, runner-indexes]
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down Expand Up @@ -216,22 +173,22 @@ jobs:
- name: Upload to Production
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
run: |
codecovcli do-upload -t ${{ secrets.CODECOV_ORG_TOKEN }} --fail-on-error
codecovcli upload-process -t ${{ secrets.CODECOV_ORG_TOKEN }} --fail-on-error
- name: Upload to Staging
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
run: |
codecovcli -u ${{ secrets.CODECOV_STAGING_URL }} do-upload -t ${{ secrets.CODECOV_ORG_TOKEN_STAGING }} --fail-on-error
codecovcli -u ${{ secrets.CODECOV_STAGING_URL }} upload-process -t ${{ secrets.CODECOV_ORG_TOKEN_STAGING }} --fail-on-error
- name: Upload to QA
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
run: |
codecovcli -u ${{ secrets.CODECOV_QA_URL }} do-upload -t ${{ secrets.CODECOV_QA_TOKEN }} --fail-on-error
codecovcli -u ${{ secrets.CODECOV_QA_URL }} upload-process -t ${{ secrets.CODECOV_QA_TOKEN }} --fail-on-error
- name: Upload to Public QA
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
run: |
codecovcli -u ${{ secrets.CODECOV_PUBLIC_QA_URL }} do-upload -t ${{ secrets.CODECOV_PUBLIC_QA_TOKEN }} --fail-on-error
codecovcli -u ${{ secrets.CODECOV_PUBLIC_QA_URL }} upload-process -t ${{ secrets.CODECOV_PUBLIC_QA_TOKEN }} --fail-on-error
storybook:
name: Run storybook
Expand Down Expand Up @@ -316,31 +273,22 @@ jobs:
run: |
npm run build
self-hosted:
name: Build Self Hosted Gazebo
runs-on: ubuntu-latest
needs: [install, test]
if: ${{ github.event.pull_request.merged == true && (github.head_ref == 'main' || startsWith(github.ref, 'refs/tags/self-hosted')) && github.repository_owner == 'codecov' }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Build self hosted
run: |
make build
- name: Log in to Docker Hub
uses: docker/[email protected]
with:
username: ${{ secrets.CODECOV_DEVOPS_DOCKER_USERNAME }}
password: ${{ secrets.CODECOV_DEVOPS_DOCKER_PASSWORD }}

- name: Push self hosted rolling
if: github.head_ref == 'main'
run: |
make push
build-self-hosted:
name: Build Self Hosted Image
secrets: inherit
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
uses: codecov/gha-workflows/.github/workflows/[email protected]
with:
repo: ${{ vars.CODECOV_IMAGE_V2 || 'codecov/self-hosted-frontend' }}
cache_requirements: false

- name: Push self hosted release
if: startsWith(github.ref, 'refs/tags/self-hosted')
run: |
make release
self-hosted:
name: Push Self Hosted Image
needs: [ build-self-hosted, test ]
secrets: inherit
if: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/main' && github.repository_owner == 'codecov' }}
uses: codecov/gha-workflows/.github/workflows/[email protected]
with:
push_rolling: true
repo: ${{ vars.CODECOV_IMAGE_V2 || 'codecov/self-hosted-frontend' }}
cache_requirements: false
43 changes: 0 additions & 43 deletions .github/workflows/create-self-hosted-release.yml

This file was deleted.

14 changes: 14 additions & 0 deletions .github/workflows/self-hosted-release-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Create Self Hosted Release PR

on:
workflow_dispatch:
inputs:
versionName:
description: 'Name of version (ie 23.9.5)'
required: true

jobs:
create-release-pr:
name: Create PR for Release ${{ github.event.inputs.versionName }}
uses: codecov/gha-workflows/.github/workflows/[email protected]
secrets: inherit
42 changes: 15 additions & 27 deletions .github/workflows/self-hosted-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,18 @@ on:
types: [closed]

jobs:
push_to_registry:
name: Tag Release ${{ github.head_ref }}
if: ${{ github.event.pull_request.merged == true && startsWith(github.head_ref, 'release/') }}
runs-on: ubuntu-latest
environment: enterprise
permissions:
contents: 'read'
id-token: 'write'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Initialize mandatory git config
run: |
git config user.name "GitHub Actions"
git config user.email [email protected]
- id: get-release-vars
name: Configure Release Vars
run: |
echo "release_version=$(cat VERSION)" >> "$GITHUB_OUTPUT"
- name: Create GH Release
uses: softprops/[email protected]
with:
token: ${{ secrets.RELEASE_GITHUB_TOKEN }}
name: Release ${{ steps.get-release-vars.outputs.release_version }}
tag_name: self-hosted-${{ steps.get-release-vars.outputs.release_version }}
generate_release_notes: true
body: Autogenerated for ${{ steps.get-release-vars.outputs.release_version }}. Created for ${{ github.event.pull_request.html_url }}
create-release:
name: Tag Release ${{ github.head_ref }} and Push Docker image to Docker Hub
if: ${{ github.event.pull_request.merged == true && startsWith(github.head_ref, 'release/') && github.repository_owner == 'codecov' }}
uses: codecov/gha-workflows/.github/workflows/[email protected]
secrets: inherit

push-image:
needs: [create-release]
if: ${{ github.event.pull_request.merged == true && startsWith(github.head_ref, 'release/') && github.repository_owner == 'codecov' }}
uses: codecov/gha-workflows/.github/workflows/[email protected]
secrets: inherit
with:
push_release: true
repo: ${{ vars.CODECOV_IMAGE_V2 || 'codecov/self-hosted-frontend' }}
cache_requirements: false
23 changes: 17 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,35 @@ export DOCKER_BUILDKIT := 1
build.local:
docker build -f docker/Dockerfile . -t ${dockerhub_image}:latest --build-arg REACT_APP_STAGE=development --build-arg REACT_APP_CODECOV_VERSION=${release_version} --build-arg REACT_APP_ENV_ARG=development

build:
docker build -f docker/Dockerfile . -t ${dockerhub_image}:rolling -t ${dockerhub_image}:${release_version}-${sha} \
build.self-hosted:
docker build -f docker/Dockerfile . -t ${dockerhub_image}:rolling \
-t ${dockerhub_image}:${release_version}-${sha} \
--build-arg REACT_APP_STAGE=${ENV} \
--build-arg REACT_APP_CODECOV_VERSION=${release_version} \
--build-arg REACT_APP_ENV_ARG=${ENV} \
--label "org.label-schema.build-date"="$(build_date)" \
--label "org.label-schema.name"="Self-Hosted Frontend" \
--label "org.label-schema.vendor"="Codecov" \
--label "org.label-schema.version"="${release_version}-${sha}" \
--squash
--label "org.label-schema.version"="${release_version}-${sha}"

push:
tag.self-hosted-rolling:
docker tag ${dockerhub_image}:${release_version}-${sha} ${dockerhub_image}:rolling

push.self-hosted-rolling:
docker push ${dockerhub_image}:rolling

release:
save.self-hosted:
docker save -o self-hosted.tar ${dockerhub_image}:${release_version}-${sha}

load.self-hosted:
docker load --input self-hosted.tar

tag.self-hosted-release:
docker tag ${dockerhub_image}:${release_version}-${sha} ${dockerhub_image}:${release_version}
docker tag ${dockerhub_image}:${release_version}-${sha} ${dockerhub_image}:latest-stable
docker tag ${dockerhub_image}:${release_version}-${sha} ${dockerhub_image}:latest-calver

push.self-hosted-release:
docker push ${dockerhub_image}:${release_version}
docker push ${dockerhub_image}:latest-stable
docker push ${dockerhub_image}:latest-calver
8 changes: 4 additions & 4 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# syntax = docker/dockerfile:1.3
FROM node:18.8.0-alpine3.15 as npm
FROM oven/bun:alpine as bun
RUN apk -U add git
RUN mkdir /home/workspace
COPY package.json /home/workspace
WORKDIR /home/workspace
RUN apk -U add git
RUN npm install
RUN bun install

FROM alpine:3.17 as uploader
USER root
Expand Down Expand Up @@ -49,7 +49,7 @@ ENV REACT_APP_ENV=$REACT_APP_ENV_ARG
ENV REACT_APP_CODECOV_VERSION=$REACT_APP_CODECOV_VERSION
ENV GENERATE_SOURCEMAP=false
RUN mkdir /home/workspace
COPY --from=npm /home/workspace/node_modules /home/workspace/node_modules
COPY --from=bun /home/workspace/node_modules /home/workspace/node_modules
WORKDIR /home/workspace
RUN apk -U add git
COPY . /home/workspace
Expand Down

0 comments on commit e5adcc5

Please sign in to comment.