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

feat: CI init #7

Merged
merged 14 commits into from
Sep 24, 2023
Merged
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
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Ignore everything in the root except some files
/*

# Unignore all files in the src directory
!src/
73 changes: 65 additions & 8 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,37 @@
{
"plugins": ["jest", "jest-formatting", "@typescript-eslint", "prettier"],
"plugins": [
"jest",
"jest-formatting",
"@typescript-eslint",
"import",
"prettier",
"deprecation"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended-type-checked",
"plugin:jest/recommended",
"plugin:prettier/recommended",
"plugin:github/recommended"
"plugin:prettier/recommended"
],
"env": {
"node": true
},
"ignorePatterns": [
"node_modules",
"dist",
"lib",
"build",
"__test__",
"**/*.spec.ts",
"**/*.test.ts"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2022,
"ecmaVersion": 13,
"project": "./tsconfig.json"
},
"rules": {
"deprecation/deprecation": "error",
"prettier/prettier": [
"error",
{
Expand All @@ -20,10 +41,46 @@
"arrowParens": "always",
"endOfLine": "auto"
}
],
"@typescript-eslint/no-namespaces": "off",
"@typescript-eslint/camelcase": "off",
"@typescript-eslint/naming-convention": [
"warn",
{
"selector": "default",
"format": [
"camelCase"
]
},
{
"selector": "variable",
"format": [
"camelCase",
"UPPER_CASE"
]
},
{
"selector": "parameter",
"format": [
"camelCase",
"snake_case"
],
"leadingUnderscore": "allow"
},
{
"selector": "typeLike",
"format": [
"PascalCase"
]
},
{
"selector": "property",
"format": [
"camelCase",
"snake_case",
"PascalCase"
]
}
]
},
"env": {
"node": true,
"jest/globals": true
}
}
17 changes: 17 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
test:
- "src/*.test.ts"
- "src/**/*.test.ts"
- "src/*.spec.ts"
- "src/**/*.spec.ts"

documentation:
- "**/*.md"
- "**/*.txt"

dependencies:
- "**/package.json"
- "**/yarn.lock"

infrastructure:
- "**/Dockerfile"
- "**/compose.yml"
35 changes: 35 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
changelog:
categories:
- title: "🚀 Features"
labels:
- enhancement
- feature

- title: "🐛 Bug Fixes"
labels:
- bug
- fix
- hotfix
- bugfix

- title: "🧰 Maintenance"
labels:
- maintenance
- refactor
- chore

- title: "📝 Documentation"
labels:
- documentation

- title: "🏗️ Infrastructure"
labels:
- infrastructure

- title: "🧪 Tests"
labels:
- test

- title: "📦 Dependencies"
labels:
- dependencies
42 changes: 42 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: 'CodeQL'

on:
schedule:
- cron: '0 0 * * 0' # Run at 00:00 UTC on Sunday
push:
branches: [main]

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

strategy:
fail-fast: false
matrix:
language: ['javascript']
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Use only 'java' to analyze code written in Java, Kotlin or both
# Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

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

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}

- name: Autobuild
uses: github/codeql-action/autobuild@v2

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: '/language:${{matrix.language}}'
39 changes: 39 additions & 0 deletions .github/workflows/delete-cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: cleanup caches by a branch

on:
pull_request:
types:
- closed

jobs:
cleanup:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Cleanup
run: |
gh extension install actions/gh-actions-cache

REPO=${{ github.repository }}
BRANCH="refs/pull/${{ github.event.pull_request.number }}/merge"

echo "Fetching list of cache key"
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH | cut -f 1 )

## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting caches..."
if [ -z "$cacheKeysForPR" ]
then
echo "No cache keys found for $BRANCH"
exit 0
fi
for cacheKey in $cacheKeysForPR
do
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
done
echo "Done"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14 changes: 14 additions & 0 deletions .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Pull Request Labeler

on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
triage:
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@v4
43 changes: 43 additions & 0 deletions .github/workflows/metrics.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Monthly issue metrics
on:
workflow_dispatch:
schedule:
# Run on the first day of every month at 00:00 JST (UTC+9)
- cron: '0 15 1 * *'

permissions:
issues: write
pull-requests: read

jobs:
build:
name: issue metrics
runs-on: ubuntu-latest

steps:
- name: Get dates for last month
shell: bash
run: |
# Calculate the first day of the previous month
first_day=$(date -d "last month" +%Y-%m-01)

# Calculate the last day of the previous month
last_day=$(date -d "$first_day +1 month -1 day" +%Y-%m-%d)

#Set an environment variable with the date range
echo "$first_day..$last_day"
echo "last_month=$first_day..$last_day" >> "$GITHUB_ENV"

- name: Run issue-metrics tool
uses: github/issue-metrics@v2
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SEARCH_QUERY: 'repo:Okabe-Junya/issue-validator is:issue is:pr created:${{ env.last_month }} -reason:"not planned"'

- name: Create issue
uses: peter-evans/create-issue-from-file@v4
with:
title: Monthly issue metrics report
token: ${{ secrets.GITHUB_TOKEN }}
content-filepath: ./issue_metrics.md
assignees: <YOUR_GITHUB_HANDLE_HERE>
19 changes: 19 additions & 0 deletions .github/workflows/reviewdog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: reviewdog eslint
on:
pull_request:
branches:
- main

jobs:
lint:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4
- uses: reviewdog/action-eslint@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
reporter: github-pr-review
eslint_flags: "--ext .ts"
58 changes: 58 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: jest test
on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
setup:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '20'

- name: Install Dependencies with Yarn
run: yarn install

- name: Cache Dependencies
uses: actions/cache@v3
with:
path: node/ci-dependency/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('yarn.lock') }}

test:
needs: setup
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
node: [18, 20]

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}

- name: Install Dependencies
run: yarn install

- name: Cache Dependencies
uses: actions/cache@v3
with:
path: node/ci-dependency/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('yarn.lock') }}

- name: Run Tests
run: yarn test
5 changes: 5 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Ignore everything in the root except some files
/*

# Unignore all files in the src directory
!src/
Loading