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

Sentry next plugin and layer0 #1

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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
7 changes: 6 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{
"presets": ["next/babel"]
"presets": ["next/babel"],
"env": {
"test": {
"plugins": ["dynamic-import-node"]
}
}
}
11 changes: 11 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
NEXT_PUBLIC_APP_STAGE=production
NEXT_PUBLIC_FEATURE_SOURCE_MAP=true
NEXT_PUBLIC_FEATURE_WIDEN_SOURCE_MAP=true
NEXT_PUBLIC_SENTRY_SAMPLE_RATE=1.0
NEXT_PUBLIC_SENTRY_TRACE_SAMPLE_RATE=1.0
NEXT_PUBLIC_FEATURE_FLAG_RUM=false
NEXT_PUBLIC_RUM_TOKEN=false
NEXT_PUBLIC_SENTRY_DSN=
SENTRY_AUTH_TOKEN=
SENTRY_ORG=
SENTRY_PROJECT=
1 change: 1 addition & 0 deletions .env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NEXT_PUBLIC_APP_STAGE=development
8 changes: 0 additions & 8 deletions .env.example

This file was deleted.

2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
**/node_modules/*
**/out/*
**/.next/*
**/.layer0/*
src/**/*.test*
106 changes: 77 additions & 29 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,47 +1,95 @@
{
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended"
// Uncomment the following lines to enable eslint-config-prettier
// Is not enabled right now to avoid issues with the Next.js repo
// "prettier",
],
"env": {
"es6": true,
"browser": true,
"es2020": true,
"jest": true,
"node": true
},
"settings": {
"react": {
"version": "detect"
}
},
"extends": [
"airbnb",
"airbnb/hooks",
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:import/typescript",
"plugin:react/recommended",
"plugin:sonarjs/recommended",
"prettier",
"prettier/@typescript-eslint",
"prettier/react"
],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint", "sonarjs", "simple-import-sort"],
"rules": {
"react/react-in-jsx-scope": 0,
"react/display-name": 0,
"react/prop-types": 0,
"@typescript-eslint/explicit-function-return-type": 0,
"@typescript-eslint/explicit-member-accessibility": 0,
"@typescript-eslint/indent": 0,
"@typescript-eslint/member-delimiter-style": 0,
"@typescript-eslint/no-explicit-any": 0,
"@typescript-eslint/no-var-requires": 0,
"@typescript-eslint/no-use-before-define": 0,
"sonarjs/no-duplicate-string": "off",
"sonarjs/cognitive-complexity": "warn",
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-member-accessibility": "off",
"@typescript-eslint/indent": "off",
"@typescript-eslint/member-delimiter-style": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": [
2,
"warn",
{
"argsIgnorePattern": "^_"
}
],
"no-console": [
"no-unused-vars": ["warn", { "varsIgnorePattern": "^_" }],
"no-use-before-define": "off",
"@typescript-eslint/no-var-requires": "off",
"jsx-a11y/anchor-is-valid": "off",
"jsx-a11y/click-events-have-key-events": "off",
"react/display-name": "off",
"react/no-array-index-key": "warn",
"react/no-unknown-property": [
2,
{
"allow": ["warn", "error"]
"ignore": ["jsx", "global"]
}
],
"react/jsx-filename-extension": [
"warn",
{
"extensions": [".js", ".jsx", ".ts", ".tsx"]
}
],
"react/jsx-one-expression-per-line": "off",
"react/prop-types": "off",
"react/react-in-jsx-scope": "off",
"react/require-default-props": "off",
"react/jsx-props-no-spreading": "off",
"no-console": [
"error",
{
"allow": ["debug", "warn", "error"]
}
],
"no-plusplus": "off",
"import/no-extraneous-dependencies": "off",
"import/named": "error",
"import/extensions": [
"error",
"ignorePackages",
{
"js": "never",
"jsx": "never",
"ts": "never",
"tsx": "never"
}
]
},
"settings": {
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"]
},
"import/resolver": {
"node": {
"extensions": [".js", ".json", ".jsx", ".ts", ".tsx"]
},
"typescript": {}
}
}
}
102 changes: 102 additions & 0 deletions .github/workflows/reusable-build-and-deploy-layer0.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
on:
workflow_call:
inputs:
environment_name:
required: true
type: string

jobs:
deployApplication:
name: App
runs-on: ubuntu-latest
steps:
- uses: actions/cache@v3
id: restore-build
with:
path: ./*
key: ${{ github.sha }}

- uses: actions/setup-node@v3
with:
node-version: '14'
cache: 'yarn'
check-latest: true

- name: Start deployment
uses: bobheadxi/[email protected]
id: deployment
with:
step: start
token: ${{ secrets.GITHUB_TOKEN }}
env: ${{inputs.environment_name}}

- name: Pull env vars
id: pull-var
run: |
sed -i 's/fileContent += (secret ? `#${key}=<SECRET VALUE>` : `${key}=${value}`) + EOL + EOL;/fileContent += (`${key}=${value}`) + EOL + EOL;/g' node_modules/@layer0/cli/commands/env/pull.js
yarn layer0:env-pull --token=${{secrets.layer0_deploy_token}} --environment=${{inputs.environment_name}} .env.production.local
sed -i 's/fileContent += (`${key}=${value}`) + EOL + EOL;/fileContent += (secret ? `#${key}=<SECRET VALUE>` : `${key}=${value}`) + EOL + EOL;/g' node_modules/@layer0/cli/commands/env/pull.js

- name: Build
id: build
run: |
yarn layer0:build
env:
SENTRY_AUTH_TOKEN: ${{secrets.sentry_auth_token}}
SENTRY_ORG: ${{secrets.sentry_org}}
SENTRY_PROJECT: ${{secrets.sentry_project}}
SENTRY_RELEASE: ${{ github.sha }}

- name: Set release commits
id: commits
run: |
yarn sentry-cli releases set-commits --auto ${{ env.SENTRY_RELEASE }}
env:
SENTRY_AUTH_TOKEN: ${{secrets.sentry_auth_token}}
SENTRY_ORG: ${{secrets.sentry_org}}
SENTRY_PROJECT: ${{secrets.sentry_project}}
SENTRY_RELEASE: ${{ github.sha }}

- name: Delete source-maps
id: clean-sourcemaps
run: |
yarn clean:sourcemaps

- name: Deploy to Layer0
id: deploy
run: |
yarn layer0:deploy --branch=${{github.ref_name}} --token=${{secrets.layer0_deploy_token}} --environment=${{inputs.environment_name}}

- name: Get deployment URLs
if: success()
id: deploy_manifest
run: |
content=$(cat .layer0/deployment-manifest.json | tr -d '\n')
echo "json=$content" >> $GITHUB_OUTPUT

- name: Check if deployment report file exists
if: steps.deploy_manifest.outputs.json == ''
run: |
echo File .layer0/deployment-manifest.json is empty or not exists
exit 1

- name: Upload deployment-manifest.json
if: success()
uses: actions/upload-artifact@v3
with:
name: deployment-manifest.json
path: .layer0/deployment-manifest.json
if-no-files-found: error

- name: Update deployment status
uses: bobheadxi/[email protected]
if: always()
with:
step: finish
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
env_url: ${{ env.DEPLOYMENT_EDGE }}
env: ${{inputs.environment_name}}
env:
DEPLOYMENT_EDGE: ${{fromJson(steps.deploy_manifest.outputs.json).environment.url}}
25 changes: 25 additions & 0 deletions .github/workflows/reusable-install-dependencies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
on: [workflow_call]

jobs:
installDependencies:
name: Dependencies
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/setup-node@v3
with:
node-version: '14'
cache: 'yarn'
check-latest: true

- name: Install dependencies
run: yarn install --prefer-offline --frozen-lockfile

- uses: actions/cache@v3
id: cache-build
with:
path: ./*
key: ${{ github.sha }}
45 changes: 45 additions & 0 deletions .github/workflows/reusable-pr-comment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
on: [workflow_call]

jobs:
prComment:
name: PR Comment
runs-on: ubuntu-latest
steps:
- name: Find pull-request ID
if: success()
uses: jwalton/[email protected]
id: finder

- name: Download a single artifact
uses: actions/download-artifact@v3
with:
name: deployment-manifest.json

- name: Get deployment URLs
if: success()
id: deploy_manifest
run: |
content=$(cat deployment-manifest.json | tr -d '\n')
echo "json=$content" >> $GITHUB_OUTPUT

- name: Check if deployment report file exists
if: steps.deploy_manifest.outputs.json == ''
run: |
echo File deployment-manifest.json is empty or not exists
exit 1

- name: Sticky Pull Request Comment
if: success()
uses: marocchino/[email protected]
with:
number: ${{ steps.finder.outputs.pr }}
recreate: true
message: |
:white_check_mark: Permalink: <${{ env.DEPLOYMENT_PERMALINK }}>
:heavy_check_mark: Edge: <${{env.DEPLOYMENT_EDGE}}>
env:
DEPLOYMENT_NUMBER: ${{fromJson(steps.deploy_manifest.outputs.json).number}}
DEPLOYMENT_PERMALINK: ${{fromJson(steps.deploy_manifest.outputs.json).url}}
DEPLOYMENT_EDGE: ${{fromJson(steps.deploy_manifest.outputs.json).environment.url}}
DEPLOYMENT_ENVIRONMENT: ${{fromJson(steps.deploy_manifest.outputs.json).environment.name}}

46 changes: 46 additions & 0 deletions .github/workflows/reusable-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
on: [workflow_call]

jobs:
formatCheck:
name: Formatting
runs-on: ubuntu-latest
steps:
- uses: actions/cache@v3
id: restore-build
with:
path: ./*
key: ${{ github.sha }}
- run: yarn format:check

lintCheck:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/cache@v3
id: restore-build
with:
path: ./*
key: ${{ github.sha }}
- run: yarn lint

typeCheck:
name: Type
runs-on: ubuntu-latest
steps:
- uses: actions/cache@v3
id: restore-build
with:
path: ./*
key: ${{ github.sha }}
- run: yarn type:check

testUnit:
name: Unit
runs-on: ubuntu-latest
steps:
- uses: actions/cache@v3
id: restore-build
with:
path: ./*
key: ${{ github.sha }}
- run: yarn test --maxWorkers=2
Loading