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

Commit

Permalink
Merge pull request #2 from directus/automation
Browse files Browse the repository at this point in the history
Add release/dependency automation
  • Loading branch information
rijkvanzanten authored Jul 15, 2022
2 parents c0f077b + a5f2084 commit 1aabda5
Show file tree
Hide file tree
Showing 10 changed files with 5,354 additions and 4 deletions.
64 changes: 62 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,65 @@
const parentConfig = require('../../.eslintrc.js');
const defaultRules = {
// No console statements in production
'no-console': process.env.NODE_ENV !== 'development' ? 'error' : 'off',
// No debugger statements in production
'no-debugger': process.env.NODE_ENV !== 'development' ? 'error' : 'off',
// Enforce prettier formatting
'prettier/prettier': 'error',
};

module.exports = {
...parentConfig,
// Stop looking for ESLint configurations in parent folders
root: true,
// Global variables: Browser and Node.js
env: {
browser: true,
node: true,
},
// Basic configuration for js files
plugins: ['@typescript-eslint', 'prettier'],
extends: ['eslint:recommended', 'prettier'],
rules: defaultRules,
parserOptions: {
ecmaVersion: 2020,
},
overrides: [
// Parse rollup configuration as module
{
files: ['rollup.config.js', 'vite.config.js'],
parserOptions: {
sourceType: 'module',
},
},
{
files: ['**/*.test.js'],
env: {
jest: true,
},
plugins: ['jest'],
},

{
files: ['*.ts'],
parserOptions: {
parser: '@typescript-eslint/parser',
},
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'],
rules: {
...defaultRules,
'vue/multi-word-component-names': 'off',
// It's recommended to turn off this rule on TypeScript projects
'no-undef': 'off',
// Allow ts-directive comments (used to suppress TypeScript compiler errors)
'@typescript-eslint/ban-ts-comment': 'off',
// Allow usage of the any type (consider to enable this rule later on)
'@typescript-eslint/no-explicit-any': 'off',
// Allow usage of require statements (consider to enable this rule later on)
'@typescript-eslint/no-var-requires': 'off',
// Allow non-null assertions for now (consider to enable this rule later on)
'@typescript-eslint/no-non-null-assertion': 'off',
// Allow unused arguments and variables when they begin with an underscore
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }],
},
},
],
};
38 changes: 38 additions & 0 deletions .github/actions/prepare/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Prepare
description: Install and build the app

runs:
using: 'composite'
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 16

- uses: pnpm/[email protected]
name: Install pnpm
id: pnpm-install
with:
version: 7
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
shell: bash
run: pnpm install
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
1 change: 1 addition & 0 deletions .github/funding.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: [directus, benhaynes, rijkvanzanten]
57 changes: 57 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Check

on:
pull_request:
branches: ['main']
push:
branches: ['main']

jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Prepare
uses: ./.github/actions/prepare

- name: Test
run: pnpm test

lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Prepare
uses: ./.github/actions/prepare

- name: Lint
run: pnpm lint

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

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

- name: Prepare
uses: ./.github/actions/prepare

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

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
25 changes: 25 additions & 0 deletions .github/workflows/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Dependabot
on: pull_request_target
permissions: read-all
jobs:
update-lockfile:
runs-on: ubuntu-latest
if: ${{ github.actor == 'dependabot[bot]' }}
permissions:
pull-requests: write
contents: write
steps:
- uses: pnpm/action-setup@v2
with:
version: 7
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ secrets.PUSH_PAT }}
- run: pnpm i --lockfile-only
- run: |
git config --global user.name github-actions[bot]
git config --global user.email github-actions[bot]@users.noreply.github.com
git add pnpm-lock.yaml
git commit -m "Update pnpm-lock.yaml"
git push
37 changes: 37 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Push Release

on:
push:
tags:
- 'v*.*.*'

permissions:
contents: read

jobs:
release:
permissions:
contents: write
name: Build & Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Prepare
uses: ./.github/actions/prepare

- name: Build dist
run: pnpm build

- name: Publish Packages
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
pnpm config set "//registry.npmjs.org/:_authToken" "${NPM_TOKEN}"
pnpm publish --access=public --no-git-checks
- name: GitHub Release
uses: softprops/action-gh-release@v1
with:
generate_release_notes: true
7 changes: 7 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
htmlWhitespaceSensitivity: "ignore",
printWidth: 120,
singleQuote: true,
useTabs: true,
proseWrap: "always",
};
21 changes: 19 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
"cleanup": "run-p cleanup:*",
"cleanup:dist": "rimraf ./dist",
"cleanup:coverage": "rimraf ./coverage",
"profile": "clinic flame -- node ./bin/directus"
"profile": "clinic flame -- node ./bin/directus",
"lint": "eslint src",
"test": "echo \"No tests exist yet\" && exit 0"
},
"keywords": [
"api",
Expand Down Expand Up @@ -78,14 +80,29 @@
"@types/js-yaml": "4.0.5",
"@types/marked": "4.0.1",
"@types/marked-terminal": "^3.1.3",
"@types/node": "^18.0.4",
"@types/yargs-parser": "^21.0.0",
"@typescript-eslint/eslint-plugin": "^5.30.6",
"@typescript-eslint/parser": "^5.30.6",
"eslint": "^8.19.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"jest": "27.3.1",
"lint-staged": "^13.0.3",
"nock": "13.2.1",
"npm-run-all": "4.1.5",
"prettier": "2.4.1",
"rimraf": "3.0.2",
"simple-git-hooks": "^2.8.0",
"ts-jest": "27.0.7",
"ts-node": "10.4.0",
"typescript": "4.5.2"
},
"gitHead": "24621f3934dc77eb23441331040ed13c676ceffd"
"simple-git-hooks": {
"pre-commit": "npx lint-staged"
},
"lint-staged": {
"*.{js,ts}": "eslint --fix"
},
"packageManager": "^[email protected]"
}
Loading

0 comments on commit 1aabda5

Please sign in to comment.