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

chore: add github workflows #26

Merged
merged 3 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
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
68 changes: 68 additions & 0 deletions .github/workflows/build-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Build & Publish

on:
pull_request:
branches:
- '**'
push:
branches:
- main
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'

jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
matrix:
package: ['backend', 'frontend']
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Environment setup
uses: ./.github/workflows/setup
- name: Build
run: |
pnpm --filter ${{ matrix.package }} build

publish:
runs-on: ubuntu-latest
needs: build
timeout-minutes: 15
if: startsWith(github.ref, 'refs/tags/v')
strategy:
matrix:
package:
- name: web-monetization-tools-backend
identifier: backend
path: backend
- name: web-monetization-tools-frontend
identifier: frontend
script_api_url: https://wmtools-backend.interledger-test.dev/
script_frontend_url: https://wmtools.interledger-test.dev/
script_ilpay_url: https://interledgerpay.com/extension/
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker build and push
uses: docker/build-push-action@v6
with:
context: ./
push: true
file: ${{ matrix.package.path }}/Dockerfile
build-args: |
${{ matrix.package.identifier == 'frontend' && format('VITE_SCRIPT_API_URL={0}', matrix.package.script_api_url) || '' }}
${{ matrix.package.identifier == 'frontend' && format('VITE_SCRIPT_FRONTEND_URL={0}', matrix.package.script_frontend_url) || '' }}
${{ matrix.package.identifier == 'frontend' && format('VITE_SCRIPT_ILPAY_URL={0}', matrix.package.script_ilpay_url) || '' }}
tags: ghcr.io/${{ github.repository_owner }}/${{ matrix.package.name }}:${{ github.ref_name }},ghcr.io/${{ github.repository_owner }}/${{ matrix.package.name }}:latest
45 changes: 45 additions & 0 deletions .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: PR Checks

on:
push:
branches:
- '!main'
pull_request:
types:
- opened
- synchronize

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
typecheck:
name: Typecheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/workflows/setup
- run: pnpm typecheck

lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Environment setup
uses: ./.github/workflows/setup
- name: Check lint
run: pnpm lint:check

format:
name: Format
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Environment setup
uses: ./.github/workflows/setup
- name: Check format
run: pnpm format:check
18 changes: 18 additions & 0 deletions .github/workflows/pr-title-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Check PR title

on:
pull_request:
branches: ['*']
types:
- edited
- opened
- synchronize

jobs:
check-pr-title:
name: Check PR Title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35 changes: 35 additions & 0 deletions .github/workflows/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: 'WMTools Environment Setup'
description: 'Installs NodeJS, PNPM, dependencies and PNPM restores cache'

runs:
# composite allows us to bundle multiple workflow steps into a single action
using: 'composite'

steps:
- name: Setup NodeJS
uses: actions/setup-node@v4
with:
node-version: 'lts/iron'

- name: Install PNPM
uses: pnpm/action-setup@v2
with:
run_install: false
# we do not need to specify PNPM's version since we have the `packageManager`
# property set in `package.json`

- name: Get PNPM store path
id: pnpm-cache
shell: bash
run: |
echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT

- name: Setup PNPM cache
uses: actions/cache@v4
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}

- name: Install dependencies
shell: bash
run: pnpm install --frozen-lockfile
2 changes: 1 addition & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"start": "build & node dist/server.js",
"build": "pnpm tsc --build tsconfig.build.json && tsc-alias -p tsconfig.build.json",
"typecheck": "pnpm tsc --noEmit"
"typecheck": "tsc --noEmit"
},
"keywords": [],
"author": "Arpi <[email protected]>",
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/components/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type ButtonProps = VariantProps<typeof buttonStyles> &
}

export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
({ intent, children, className, variant, ...props }, ref) => {
({ intent, children, className, ...props }, ref) => {
return (
<ButtonOrLink
ref={ref}
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/components/CopyButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface CopyButtonProps
}

export const CopyButton = forwardRef<HTMLButtonElement, CopyButtonProps>(
({ value, size, ctaText, afterCtaText, variant, ...props }, ref) => {
({ value, size, ctaText, afterCtaText, variant }, ref) => {
const [isCopied, setIsCopied] = useState(false)

useEffect(() => {
Expand Down
Loading