Skip to content

Commit

Permalink
feat(infrastructure): add github workflows for monorepo
Browse files Browse the repository at this point in the history
  • Loading branch information
Goldziher committed Aug 15, 2023
1 parent 8567e79 commit dc20113
Show file tree
Hide file tree
Showing 5 changed files with 166 additions and 96 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/ci-tests-go.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: 'Tests (Golang)'
on:
push:
pull_request:
branches:
- main
paths:
- 'go-services/**'
- 'go-shared/**'
- 'go.*'
env:
GCP_OIDC_PROVIDER_NAME: github-provider
GCP_PROJECT_ID: basemind-ai-development
GCP_PROJECT_NUMBER: 78794879644
GCP_SERVICE_ACCOUNT_NAME: firebase-adminsdk-frgvx
GCP_WORKLOAD_IDENTITY_POOL: dev-pool
jobs:
test:
needs: setup
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v3

- name: Setup Golang
uses: actions/setup-go@v4
with:
go-version: '1.21'
- name: Load cached Golang dependencies
id: cached-go-dependencies
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: go-${{ inputs.go_version }}-v1.0-${{ hashFiles('**/go.sum') }}
- name: Install Golang dependencies
if: steps.cached-go-dependencies.outputs.cache-hit != 'true'
shell: bash
run: go get -v -t ./...

- name: Authenticate with GCP
id: auth
uses: google-github-actions/[email protected]
with:
workload_identity_provider: 'projects/${GCP_PROJECT_NUMBER}/locations/global/workloadIdentityPools/${GCP_WORKLOAD_IDENTITY_POOL}/providers/${GCP_OIDC_PROVIDER_NAME}'
service_account: '${GCP_SERVICE_ACCOUNT_NAME}@${GCP_PROJECT_ID}.iam.gserviceaccount.com'
- name: Test
run: go test ./...
51 changes: 51 additions & 0 deletions .github/workflows/ci-tests-ts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: 'Tests (TS)'
on:
push:
pull_request:
branches:
- main
paths:
- 'ts-services/**'
- 'ts-shared/**'
- 'tsconfig.json'
- 'package.json'
- 'pnpm-lock.yaml'
- 'pnpm-workspace.yaml'
- 'vitest.*'
env:
NODE_OPTIONS: '--max_old_space_size=4096'
jobs:
test:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 20
- name: Install pnpm
uses: pnpm/[email protected]
id: pnpm-install
with:
version: 8
- name: Setup pnpm cache
id: pnpm-cache
run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
name: Load cached Node dependencies
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: ${{ runner.os }}-pnpm-store-
- name: Install Node dependencies
run: pnpm install -r

- name: Test
run: pnpm run test:coverage
- name: Coverage
uses: davelosert/vitest-coverage-report-action@v2
64 changes: 64 additions & 0 deletions .github/workflows/ci-validate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: 'Validate'
on:
push:
pull_request:
branches:
- main
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Setup Golang
uses: actions/setup-go@v4
with:
go-version: '1.21'
- name: Load cached Golang dependencies
id: cached-go-dependencies
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: go-${{ inputs.go_version }}-v1.0-${{ hashFiles('**/go.sum') }}
- name: Install Golang dependencies
if: steps.cached-go-dependencies.outputs.cache-hit != 'true'
shell: bash
run: go get -v -t ./...

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 20
- name: Install pnpm
uses: pnpm/[email protected]
id: pnpm-install
with:
version: 8
- name: Setup pnpm cache
id: pnpm-cache
run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
name: Load cached Node dependencies
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: ${{ runner.os }}-pnpm-store-
- name: Install Node dependencies
run: pnpm install -r

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install Pre-Commit
run: python -m pip install pre-commit && pre-commit install
- name: Load cached Pre-Commit Dependencies
id: cached-pre-commit-dependencies
uses: actions/cache@v3
with:
path: ~/.cache/pre-commit/
key: pre-commit-4|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
- name: Execute Pre-Commit
run: pre-commit run --show-diff-on-failure --color=always --all-files
92 changes: 0 additions & 92 deletions .github/workflows/ci.yaml

This file was deleted.

4 changes: 0 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ repos:
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/hadolint/hadolint
rev: v2.12.1-beta
hooks:
- id: hadolint
- repo: https://github.com/pre-commit/mirrors-eslint
rev: 'v8.47.0'
hooks:
Expand Down

0 comments on commit dc20113

Please sign in to comment.