Skip to content

Commit

Permalink
feat(lib): hCaptcha loader (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
faris-imi authored Oct 11, 2023
1 parent 2db76e3 commit b167a1a
Show file tree
Hide file tree
Showing 47 changed files with 6,614 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
DEBUG="false"
WATCH="false"
BUILD="production"

SENTRY_DSN_TOKEN=""
NPM_AUTH_TOKEN=""
39 changes: 39 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"env": {
"node": true,
"es2020": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
"indent": [
"error",
2
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
],
"@typescript-eslint/no-explicit-any": [
"off"
]
}
}
11 changes: 11 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# These owners will be the default owners for everything in
# the repo. Unless a later match takes precedence,they will
# be requested for review when someone opens a pull request.
* @hCaptcha/react-reviewers

# Javascript Owners
*.js @hCaptcha/react-reviewers

# Github Action Owners
.github/actions @hCaptcha/react-reviewers
.github/workflow @hCaptcha/react-reviewers
23 changes: 23 additions & 0 deletions .github/actions/dependencies/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Install dependencies

runs:
using: "composite"

steps:
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Setup dependency cache
uses: actions/cache@v3
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 dependencies
shell: bash
run: pnpm install
18 changes: 18 additions & 0 deletions .github/actions/environment/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Setup environment

runs:
using: "composite"

steps:
- name: Setup pnpm
uses: pnpm/[email protected]
with:
version: 8.x
run_install: false

- name: Setup node
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'pnpm'
registry-url: 'https://registry.npmjs.org'
24 changes: 24 additions & 0 deletions .github/actions/playwright/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Install playwright

runs:
using: "composite"

steps:
- name: Store Playwright's Version
shell: bash
run: |
PLAYWRIGHT_VERSION=$(pnpm ls @playwright/test --depth 0 | grep @playwright | sed 's/.*@//')
echo "Playwright's Version: $PLAYWRIGHT_VERSION"
echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV
- name: Cache playwright browsers per version
id: cache-playwright-browsers
uses: actions/cache@v3
with:
path: ~/.cache/ms-playwright
key: playwright-browsers-${{ env.PLAYWRIGHT_VERSION }}

- name: Setup playwright
if: steps.cache-playwright-browsers.outputs.cache-hit != 'true'
shell: bash
run: npx playwright install --with-deps
12 changes: 12 additions & 0 deletions .github/actions/setup/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Setup environment and dependencies

runs:
using: "composite"

steps:
- name: Setup environment
uses: ./.github/actions/environment
- name: Install dependencies
uses: ./.github/actions/dependencies
- name: Install playwright browsers
uses: ./.github/actions/playwright
30 changes: 30 additions & 0 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: CD

on:
release:
types: [ released ]

jobs:

publish:
name: Publish
environment: npm
runs-on: ubuntu-latest

steps:
- name: Check out branch
uses: actions/checkout@v3
- name: Setup environment and dependencies
uses: ./.github/actions/setup
- name: Build lib
shell: bash
run: pnpm run build:lib
env:
BUILD: production
DEBUG: false
SENTRY_DSN_TOKEN: ${{ secrets.SENTRY_DSN_TOKEN }}
- name: Publish package
shell: bash
run: pnpm publish --no-git-checks --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
47 changes: 47 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: CI

on:
push:
branches:
- main

env:
CI: true

jobs:

setup:
name: Setup
runs-on: ubuntu-latest

steps:
- name: Check out branch
uses: actions/checkout@v3
- name: Setup environment and dependencies
uses: ./.github/actions/setup

test_integration:
name: Test Integration
runs-on: ubuntu-latest

needs: [Setup]

steps:
- name: Check out branch
uses: actions/checkout@v3
- name: Setup environment and dependencies
uses: ./.github/actions/setup
- name: Run Build
run: pnpm run build:lib
env:
BUILD: production
DEBUG: false
- run: pnpm run test:integration
env:
CI: true
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-results
path: playwright/__test__/test-results/
retention-days: 30
53 changes: 53 additions & 0 deletions .github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Pull Request

on:
push:
branches:
- '**'
- '!main'
pull_request:
branches:
- '**'
- '!main'

jobs:

setup:
name: Setup
runs-on: ubuntu-latest

steps:
- name: Check out branch
uses: actions/checkout@v3
- name: Setup environment and dependencies
uses: ./.github/actions/setup

test_style:
name: Lint & Typecheck
runs-on: ubuntu-latest

needs: [setup]

steps:
- name: Check out branch
uses: actions/checkout@v3
- name: Setup environment and dependencies
uses: ./.github/actions/setup
- name: Check Lint
run: pnpm run test:lint
- name: Check Types
run: pnpm run test:types

test_unit:
name: Unit Tests
runs-on: ubuntu-latest

needs: [setup]

steps:
- name: Check out branch
uses: actions/checkout@v3
- name: Setup environment and dependencies
uses: ./.github/actions/setup
- name: Run Unit Tests
run: pnpm run test:unit
Loading

0 comments on commit b167a1a

Please sign in to comment.