Skip to content
This repository has been archived by the owner on Jun 25, 2024. It is now read-only.

Commit

Permalink
feat: setup gatsby, commitlint, vitest, playwright, tw, i18n, actions
Browse files Browse the repository at this point in the history
  • Loading branch information
nico-i committed Feb 2, 2024
1 parent e0a4e63 commit 62656f5
Show file tree
Hide file tree
Showing 34 changed files with 6,404 additions and 475 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/pagespeed-insights.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: PSI-SVG Action

on:
workflow_run:
workflows: ["Webhook Triggered Workflow"]
types:
- completed
workflow_dispatch:

jobs:
run-psi-svg:
runs-on: ubuntu-latest
env:
SITE_URL: ${{ vars.SITE_URL }}
PSI_SVG_OUTPUT_PATH: ${{ vars.PSI_SVG_OUTPUT_PATH }}
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install Node.js
uses: actions/setup-node@v2
with:
node-version: 21

- name: Run PSI-SVG
run: |
npx psi-svg $SITE_URL $PSI_SVG_OUTPUT_PATH --strategy=desktop
- name: Upload output as artifact
uses: actions/upload-artifact@v2
with:
name: psi-svg-output
path: ${{ env.PSI_SVG_OUTPUT_PATH }}
27 changes: 27 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Playwright Tests
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
run: npm install -g yarn && yarn
- name: Install Playwright Browsers
run: yarn playwright install --with-deps
- name: Run Playwright tests
run: yarn playwright test
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
24 changes: 24 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
on:
push:
branches:
- main

permissions:
contents: write
pull-requests: write

name: release-please

jobs:
release-please:
runs-on: ubuntu-latest
steps:
- uses: google-github-actions/release-please-action@v4
with:
# this assumes that you have created a personal access token
# (PAT) and configured it as a GitHub action secret named
# `MY_RELEASE_PLEASE_TOKEN` (this secret name is not important).
token: ${{ secrets.MY_RELEASE_PLEASE_TOKEN }}
# this is a built-in strategy in release-please, see "Action Inputs"
# for more options
release-type: simple
142 changes: 141 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,144 @@
# Created by https://www.toptal.com/developers/gitignore/api/node
# Edit at https://www.toptal.com/developers/gitignore?templates=node

### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
public
src/gatsby-types.d.ts

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

### Node Patch ###
# Serverless Webpack directories
.webpack/

# Optional stylelint cache

# SvelteKit build / generate output
.svelte-kit

# End of https://www.toptal.com/developers/gitignore/api/node
1 change: 1 addition & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx --no -- commitlint --edit $1
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npm test
1 change: 1 addition & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pnpm test
File renamed without changes
50 changes: 50 additions & 0 deletions commitlint.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
module.exports = {
extends: ["@commitlint/config-conventional"],
rules: {
"require-spent": [2, "always"],
},
plugins: [
{
rules: {
"require-spent": ({ raw }: { raw: string }) => {
const commitMessage = raw.trim();

const msgSplit = commitMessage.split("\n");
if (msgSplit.length < 3)
return [
false,
`'/spent' directive must be in new line separated by another new line`,
]; // ensure that commit message has more than 1 line

if (msgSplit[1] !== "")
return [
false,
`'/spent' directive must be separated by another new line`,
]; // ensure that commit message has more than 1 line

const spentSplit = msgSplit[msgSplit.length - 1].split(" ");
const isCorrectCommand =
spentSplit[0] === "/spent" || spentSplit[0] === "/spend";
if (spentSplit.length < 2 || !isCorrectCommand)
return [
false,
"the last line of a commit must be a '/spent' directive",
]; // ensure that commit message ends with '/spent'

const spentTimeValue = spentSplit[spentSplit.length - 1].trim();
const regex = /^(\d|[1-5]\d)m|(([1-9]|[1-4]\d)h(\d|[1-5]\d)?m?)$/; // 1h30, 30m, 1h, 1h30m, 1h30, 1h30m
const matches = regex.exec(spentTimeValue);

if (!matches || matches[0].length !== spentTimeValue.length) {
// ensure that spent time value is valid
return [
false,
"Commit message must end with a valid spent time with the format '/spent 1h30' or '/spent 30m' or '/spent 1h'",
];
}
return [true];
},
},
},
],
};
18 changes: 18 additions & 0 deletions e2e/example.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { test, expect } from '@playwright/test';

test('has title', async ({ page }) => {
await page.goto('https://playwright.dev/');

// Expect a title "to contain" a substring.
await expect(page).toHaveTitle(/Playwright/);
});

test('get started link', async ({ page }) => {
await page.goto('https://playwright.dev/');

// Click the get started link.
await page.getByRole('link', { name: 'Get started' }).click();

// Expects page to have a heading with the name of Installation.
await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible();
});
1 change: 0 additions & 1 deletion gatsby-browser.js

This file was deleted.

1 change: 1 addition & 0 deletions gatsby-browser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import "./src/styles/global.css"; // necessary for Tailwind CSS
Loading

0 comments on commit 62656f5

Please sign in to comment.