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

Add Bun, remove publish frontend step #19

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all 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
80 changes: 20 additions & 60 deletions .github/workflows/react.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,95 +2,55 @@ name: React Project Workflow
on:
workflow_call:
inputs:
# Mandatory inputs
imageName:
required: TRUE
type: string
githubRef:
required: true
type: string
gitSha:
required: true
type: string
# Optional finetuning inputs
path:
required: False
type: string
default: .
dockerfile:
nodeVersion:
required: False
type: string
default: Dockerfile
skipReactCheck: # NOTE: Use with CAUTION!
required: False
type: boolean
default: false
nodeVersion:
default: "14"
dependencyManager:
required: False
type: string
default: 14
secrets:
DOCKER_USERNAME:
required: true
DOCKER_PASSWORD:
required: true
description: "Dependency manager to use (e.g. yarn, bun)"
default: "yarn"
jobs:
react-check:
name: React Check
runs-on: ubuntu-latest
if: ${{ !inputs.skipReactCheck }}
steps:
- uses: actions/checkout@v2
- name: Cache
- name: Cache (yarn)
uses: actions/cache@v2
with:
path: "**/node_modules"
key: v0-${{ hashFiles('${{ inputs.path }}/yarn.lock') }}
if: ${{ inputs.dependencyManager == 'yarn' }}
- name: Cache (bun)
uses: actions/cache@v2
with:
path: |-
**/node_modules
**/.bun
key: v0-${{ hashFiles('${{ inputs.path }}/bun.lockb') }}
if: ${{ inputs.dependencyManager == 'bun' }}
- name: Install Dependencies
run: |-
cd ${{ inputs.path }}
yarn install --frozen-lockfile
${{ inputs.dependencyManager }} install --frozen-lockfile
- name: Lint
run: |-
cd ${{ inputs.path }}
yarn lint
${{ inputs.dependencyManager }} lint
- name: Test
run: |-
cd ${{ inputs.path }}
yarn test
${{ inputs.dependencyManager }} run test
- name: Upload Code Coverage
run: |-
ROOT=$(pwd)
cd ${{ inputs.path }}
yarn run codecov -p $ROOT -F frtype=local,src=/tmp/.buildx-cacheontend
${{ inputs.dependencyManager }} run codecov -p $ROOT -F frtype=local,src=/tmp/.buildx-cacheontend
container:
image: node:${{ inputs.nodeVersion }}
publish-frontend:
name: Publish frontend
runs-on: ubuntu-latest
needs: react-check
if: |
always() &&
(needs.react-check.result == 'success' || needs.react-check.result == 'skipped')
steps:
- uses: actions/checkout@v2
- uses: docker/setup-qemu-action@v1
- uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: buildx-publish-frontend
- uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build/Publish
uses: docker/build-push-action@v2
with:
context: ${{ inputs.path }}
file: ${{ inputs.path }}/${{ inputs.dockerfile }}
push: ${{ inputs.githubRef == 'master' }}
cache-from: type=local,src=/tmp/.buildx-cache,type=registry,ref=pennlabs/${{ inputs.imageName }}:latest
cache-to: type=local,dest=/tmp/.buildx-cache
tags: pennlabs/${{ inputs.imageName }}:latest,pennlabs/${{ inputs.imageName }}:${{ inputs.gitSha }}
image: node:${{ inputs.nodeVersion }}