From afb1297030b29137be09d721e37e13f1c3f7732c Mon Sep 17 00:00:00 2001 From: Radu-Cristian Popa Date: Thu, 7 Nov 2024 12:00:08 +0200 Subject: [PATCH 1/3] Add initial workflows --- .github/workflows/build-publish.yml | 68 ++++++++++++++++++++++++++++ .github/workflows/pr-checks.yml | 45 ++++++++++++++++++ .github/workflows/pr-title-check.yml | 18 ++++++++ .github/workflows/setup/action.yml | 35 ++++++++++++++ backend/package.json | 2 +- 5 files changed, 167 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/build-publish.yml create mode 100644 .github/workflows/pr-checks.yml create mode 100644 .github/workflows/pr-title-check.yml create mode 100644 .github/workflows/setup/action.yml diff --git a/.github/workflows/build-publish.yml b/.github/workflows/build-publish.yml new file mode 100644 index 0000000..aa559bf --- /dev/null +++ b/.github/workflows/build-publish.yml @@ -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: + script_frontend_url: + 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 diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml new file mode 100644 index 0000000..eb9ab6c --- /dev/null +++ b/.github/workflows/pr-checks.yml @@ -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 diff --git a/.github/workflows/pr-title-check.yml b/.github/workflows/pr-title-check.yml new file mode 100644 index 0000000..0380877 --- /dev/null +++ b/.github/workflows/pr-title-check.yml @@ -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 }} diff --git a/.github/workflows/setup/action.yml b/.github/workflows/setup/action.yml new file mode 100644 index 0000000..bd97a38 --- /dev/null +++ b/.github/workflows/setup/action.yml @@ -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 diff --git a/backend/package.json b/backend/package.json index 162a37e..20a3c45 100644 --- a/backend/package.json +++ b/backend/package.json @@ -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 ", From 1ec32d64f3ee5e9fe60053d9b0e4cd73613c77c7 Mon Sep 17 00:00:00 2001 From: Arpi Date: Thu, 7 Nov 2024 12:12:27 +0200 Subject: [PATCH 2/3] lint fixes --- frontend/app/components/Button.tsx | 2 +- frontend/app/components/CopyButton.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/app/components/Button.tsx b/frontend/app/components/Button.tsx index 855f395..08dba6c 100644 --- a/frontend/app/components/Button.tsx +++ b/frontend/app/components/Button.tsx @@ -33,7 +33,7 @@ type ButtonProps = VariantProps & } export const Button = forwardRef( - ({ intent, children, className, variant, ...props }, ref) => { + ({ intent, children, className, ...props }, ref) => { return ( ( - ({ value, size, ctaText, afterCtaText, variant, ...props }, ref) => { + ({ value, size, ctaText, afterCtaText, variant }, ref) => { const [isCopied, setIsCopied] = useState(false) useEffect(() => { From fb384b1a3c36dd553138edfa288ab5335e9159cf Mon Sep 17 00:00:00 2001 From: Radu-Cristian Popa Date: Thu, 7 Nov 2024 12:34:16 +0200 Subject: [PATCH 3/3] Update URLs --- .github/workflows/build-publish.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-publish.yml b/.github/workflows/build-publish.yml index aa559bf..ca7c0e0 100644 --- a/.github/workflows/build-publish.yml +++ b/.github/workflows/build-publish.yml @@ -39,8 +39,8 @@ jobs: path: backend - name: web-monetization-tools-frontend identifier: frontend - script_api_url: - script_frontend_url: + 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