Skip to content

Commit

Permalink
Merge pull request #5 from decentraland/feat/add-husky-and-gh-actions
Browse files Browse the repository at this point in the history
feat: Add husky and GH actions
  • Loading branch information
LautaroPetaccio authored Nov 9, 2023
2 parents 5f78079 + 7e7b9e2 commit b9f0832
Show file tree
Hide file tree
Showing 22 changed files with 418 additions and 53 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-env node */
module.exports = {
extends: ['@dcl/eslint-config/dapps'],
ignorePatterns: ['.eslintrc.cjs', 'jest.config.ts'],
ignorePatterns: ['.eslintrc.cjs', 'jest.config.ts', 'scripts/prebuild.cjs'],
parserOptions: {
project: ['tsconfig.json']
}
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/audit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Audit

on: [push, pull_request]

jobs:
audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
- name: Install
run: npm install --legacy-peer-deps
- name: Audit signatures
run: npm audit signatures
57 changes: 57 additions & 0 deletions .github/workflows/build-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Build and release

on:
push:
branches:
- main
release:
types:
- created

jobs:
build-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
- name: Use Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: 'npm'
- name: Set package.json version
uses: menduz/oddish-action@master
with:
deterministic-snapshot: true
only-update-versions: true
- name: Install
run: npm install --legacy-peer-deps
env:
HUSKY: 0
- name: Build
run: npm run build
env:
NODE_PATH: 'src'
NODE_OPTIONS: '--max-old-space-size=6144'
- name: Publish
uses: menduz/oddish-action@master
with:
cwd: './dist'
deterministic-snapshot: true
provenance: false
registry-url: 'https://registry.npmjs.org'
access: public
gitlab-token: ${{ secrets.GITLAB_CDN_DEPLOYER_TOKEN }}
gitlab-pipeline-url: ${{ secrets.GITLAB_CDN_DEPLOYER_URL }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create Sentry release
if: github.event_name == 'release' && github.event.action == 'created'
uses: getsentry/action-release@v1
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
with:
sourcemaps: ${{ github.workspace }}/dist
version: '${{ vars.SENTRY_RELEASE_PREFIX }}@${{ github.event.release.tag_name }}'
url_prefix: '~'
28 changes: 28 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: 'CodeQL'

on:
schedule:
- cron: '59 23 * * *'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: javascript

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: '/language:javascript'
45 changes: 45 additions & 0 deletions .github/workflows/set-rollout-manual.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Set rollout - Manual

on:
workflow_dispatch:
inputs:
packageVersion:
description: 'NPM Version of the release (@dcl/auth-site)'
required: true
default: ''
deploymentDomain:
type: 'choice'
description: 'Deployment domain'
required: true
default: '.zone'
options:
- .zone
- .today
- .org
rolloutPercentage:
description: 'The percentage for this rollout'
required: true
default: '100'

jobs:
set-manual-rollout:
runs-on: ubuntu-latest
steps:
- uses: hmarr/debug-action@v2
- name: Set Rollout
uses: decentraland/set-rollout-action@main
with:
token: ${{ secrets.GITHUB_TOKEN }}

# Repo deployment info
ref: ${{ github.event.ref }}
sha: ${{ github.sha }}

# CDN information
packageName: '@dcl/auth-site'
packageVersion: ${{ github.event.inputs.packageVersion }}

# Rollout information
deploymentDomain: auth.decentraland${{ github.event.inputs.deploymentDomain }}
deploymentName: '_site'
percentage: ${{ github.event.inputs.rolloutPercentage }}
48 changes: 48 additions & 0 deletions .github/workflows/set-rollout.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Set rollout

on: [deployment_status]

jobs:
set-rollout:
if: ${{ github.event.deployment.task == 'upload-to-cdn' && github.event.deployment_status.state == 'success' }}
runs-on: ubuntu-latest
steps:
- uses: hmarr/debug-action@v2

# Dev
- name: Set Rollout - Development
uses: decentraland/set-rollout-action@main
with:
token: ${{ secrets.GITHUB_TOKEN }}

# Repo deployment info
ref: ${{ github.event.deployment.ref }}
sha: ${{ github.event.deployment.sha }}

# CDN information
packageName: ${{ github.event.deployment.payload.packageName }}
packageVersion: ${{ github.event.deployment.payload.packageVersion }}

# Rollout information
deploymentDomain: 'auth.decentraland.zone'
deploymentName: '_site'
percentage: 100

# Stg
- name: Set Rollout - Staging
uses: decentraland/set-rollout-action@main
with:
token: ${{ secrets.GITHUB_TOKEN }}

# Repo deployment info
ref: ${{ github.event.deployment.ref }}
sha: ${{ github.event.deployment.sha }}

# CDN information
packageName: ${{ github.event.deployment.payload.packageName }}
packageVersion: ${{ github.event.deployment.payload.packageVersion }}

# Rollout information
deploymentDomain: 'auth.decentraland.today'
deploymentName: '_site'
percentage: 100
22 changes: 22 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Test

on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
- name: Use Node.js 18.x
uses: actions/setup-node@v1
with:
node-version: 18.x
- name: Install
run: npm install --legacy-peer-deps
- name: Test
run: npm run test:coverage
if: ${{ always() }}
# - name: report coverage
# uses: coverallsapp/github-action@main
# with:
# github-token: ${{ secrets.GITHUB_TOKEN }}
15 changes: 15 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

FILES=$(git diff --cached --name-only --diff-filter=ACMR | sed 's| |\\ |g' | { grep -E '(js|ts|tsx|json|yml|md|html|css)$' || true; })

if [ -z "$FILES" ]; then
exit 0
fi

TS_FILES=$(git diff --cached --name-only --diff-filter=ACMR | sed 's| |\\ |g' | { grep -E '(js|ts|tsx)$' || true; })

if [[ ! -z "$TS_FILES" ]];then
echo "Running lints"
npm run pre-commit:fix:code -- $TS_FILES
fi
6 changes: 3 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<!doctype html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<link rel="icon" type="image/x-icon" href="favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>
<title>Decentraland | Authorization</title>
</head>
<body>
<div id="root"></div>
Expand Down
37 changes: 11 additions & 26 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 10 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"name": "auth-app",
"private": true,
"name": "@dcl/auth-site",
"description": "Auth website",
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"prebuild": "node scripts/prebuild.cjs",
"test": "jest",
"test:coverage": "npm run test -- --coverage",
"preview": "vite preview",
Expand All @@ -19,6 +20,10 @@
"node": ">=18.0.0",
"npm": ">=9.0.0"
},
"repository": {
"type": "git",
"url": "https://github.com/decentraland/auth.git"
},
"dependencies": {
"@dcl/crypto": "^3.4.5",
"@dcl/schemas": "^9.8.0",
Expand All @@ -27,7 +32,7 @@
"@magic-ext/oauth": "^15.1.1",
"ajv": "^8.12.0",
"classnames": "^2.3.2",
"decentraland-connect": "^5.1.0",
"decentraland-connect": "^5.2.1",
"decentraland-ui": "^4.27.7",
"ethers": "^6.8.0",
"magic-sdk": "^21.2.0",
Expand Down Expand Up @@ -58,5 +63,6 @@
"ts-node": "^10.9.1",
"typescript": "^5.0.2",
"vite": "^4.4.5"
}
},
"homepage": ""
}
21 changes: 21 additions & 0 deletions public/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "@dcl/auth-site",
"version": "0.0.0",
"description": "Auth website",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"decentraland",
"profile",
"site"
],
"author": "Decentraland",
"license": "Apache-2.0",
"repository": {
"type": "git",
"url": "https://github.com/decentraland/auth.git"
},
"homepage": ""
}
Loading

0 comments on commit b9f0832

Please sign in to comment.