Skip to content

Commit

Permalink
test: docker build client
Browse files Browse the repository at this point in the history
  • Loading branch information
majkshkurti committed Aug 18, 2023
1 parent 8e8c312 commit 37bea82
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 8 deletions.
12 changes: 12 additions & 0 deletions .github/actions/client-cache-build/action.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
########################################################################################
# "client-cache-build" composite action for client build #
#--------------------------------------------------------------------------------------#
# #
# Usage in workflows steps: #
# #
# - name: 🏗️ Monorepo build #
# uses: ./.github/actions/client-cache-build #
# with: #
# cwd: ${{ github.workspace }}/apps/goat # (default = '.') #
########################################################################################

name: "Cache production build binaries"
description: "Cache or restore if necessary"

Expand Down
1 change: 0 additions & 1 deletion .github/actions/pnpm-install/action.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
########################################################################################
# "pnpm install" composite action for pnpm 7/8+ #
#--------------------------------------------------------------------------------------#
# Requirement: @setup/node should be run before #
# #
# Usage in workflows steps: #
# #
Expand Down
24 changes: 22 additions & 2 deletions .github/actions/poetry-install/action.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
########################################################################################
# "poetry install" composite action for client build #
#--------------------------------------------------------------------------------------#
# #
# Usage in workflows steps: #
# #
# - name: 📥 Poetry install #
# uses: ./.github/actions/poetry-install #
# with: #
# cwd: ${{ github.workspace }}/apps/api # (default = '.') #
########################################################################################

name: "Poetry install"
description: "Run poetry install with cache enabled"

Expand Down Expand Up @@ -28,18 +40,26 @@ runs:

- name: Install Poetry
if: steps.cached-poetry.outputs.cache-hit != 'true'
uses: snok/install-poetry@v1.3.3
uses: snok/install-poetry@v1.3.4
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

- name: Cache rotation keys
id: cache-rotation
shell: bash
run: |
echo "YEAR_MONTH=$(/bin/date -u "+%Y%m")" >> $GITHUB_OUTPUT
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('${{ inputs.cwd }}/poetry.lock') }}
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ steps.cache-rotation.outputs.YEAR_MONTH }}-${{ hashFiles('${{ inputs.cwd }}/poetry.lock') }}
restore-keys: |
venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ steps.cache-rotation.outputs.YEAR_MONTH }}-
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
Expand Down
13 changes: 10 additions & 3 deletions .github/workflows/client-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@ concurrency:


jobs:
files-changed:
client-changed:
name: detect-changes
runs-on: ubuntu-latest
timeout-minutes: 3
permissions:
pull-requests: read
contents: read
outputs:
client-goat: ${{ steps.changes.outputs.client-goat }}
goat: ${{ steps.changes.outputs.goat }}
steps:
- uses: actions/checkout@v3
- uses: dorny/paths-filter@v2
id: changes
with:
filters: |
client-goat:
goat:
- 'app/client/apps/goat/**'
- 'app/client/packages/**'
- 'app/client/package.json'
Expand All @@ -55,6 +55,13 @@ jobs:
uses: ./.github/workflows/client-production-build.yml
secrets: inherit

# TODO: add e2e tests
# e2e:
# name: E2E tests
# needs: [client-changed, typecheck, lint, build]
# uses: ./.github/workflows/client-test.yml
# secrets: inherit

analyze:
name: analyze
needs: build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/client-production-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
enable-corepack: true
cwd: ${{ github.workspace }}/app/client

- name: 🏗️ Build client
- name: 🏗️ Monorepo build
uses: ./.github/actions/client-cache-build
with:
cwd: ${{ github.workspace }}/app/client
69 changes: 69 additions & 0 deletions .github/workflows/client-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: "Client - Release"

on:
push:
branches: [dev, main, feature/add-map-page]
paths:
- "app/client/**"
workflow_dispatch:

defaults:
run:
working-directory: app/client

jobs:
client-changed:
name: detect-changes
runs-on: ubuntu-latest
timeout-minutes: 3
permissions:
pull-requests: read
contents: read
outputs:
goat: ${{ steps.changes.outputs.goat }}
steps:
- uses: actions/checkout@v3
- uses: dorny/paths-filter@v2
id: changes
with:
filters: |
client-goat:
- 'app/client/apps/goat/**'
- 'app/client/packages/**'
- 'app/client/package.json'
- 'app/client/pnpm-lock.yaml'
- 'app/client/.prettier*'
release-goat:
name: release-goat
needs: client-changed
if: ${{ needs.client-changed.outputs.goat == 'true' }}
runs-on: ubuntu-latest
steps:
- name: 📥 Checkout
uses: actions/checkout@v3
- uses: docker/setup-buildx-action@v1
- name: 🐳 Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: 🐳 Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: goatcommunity/client
- name: 🐳 Build changed client
uses: docker/build-push-action@v2
with:
context: ./app/client
file: ./app/client/apps/goat/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
platforms: linux/amd64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: 🐳 Image digest
run: echo ${{ steps.release-goat.outputs.digest }}
3 changes: 2 additions & 1 deletion app/client/.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ yarn-error.log*

.vscode
.github
**/.turbo
**/.turbo
.env

0 comments on commit 37bea82

Please sign in to comment.