Skip to content

Commit 575a205

Browse files
committed
feat: 👷 Add Conventions Verification Tools and Automation
1 parent d4b6a29 commit 575a205

11 files changed

Lines changed: 214 additions & 4 deletions

.eslintrc.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
module.exports = {
2+
parser: '@typescript-eslint/parser',
3+
parserOptions: {
4+
project: 'tsconfig.json',
5+
tsconfigRootDir: __dirname,
6+
sourceType: 'module',
7+
},
8+
plugins: ['@typescript-eslint/eslint-plugin'],
9+
extends: [
10+
'plugin:@typescript-eslint/recommended',
11+
'plugin:prettier/recommended',
12+
],
13+
root: true,
14+
env: {
15+
node: true,
16+
},
17+
ignorePatterns: ['.eslintrc.js', 'commitlint.config.js'],
18+
rules: {
19+
'@typescript-eslint/interface-name-prefix': 'off',
20+
'@typescript-eslint/explicit-function-return-type': 'off',
21+
'@typescript-eslint/explicit-module-boundary-types': 'off',
22+
'@typescript-eslint/no-explicit-any': 'off',
23+
},
24+
};

.github/workflows/release.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Release
2+
on:
3+
push:
4+
branches:
5+
- main
6+
- staging
7+
- production
8+
9+
pull_request:
10+
branches:
11+
- main
12+
13+
permissions:
14+
contents: read # for checkout
15+
16+
jobs:
17+
release:
18+
name: Release
19+
runs-on: ubuntu-latest
20+
permissions:
21+
contents: write # to be able to publish a GitHub release
22+
issues: write # to be able to comment on released issues
23+
pull-requests: write # to be able to comment on released pull requests
24+
id-token: write # to enable use of OIDC for npm provenance
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v3
28+
with:
29+
fetch-depth: 0
30+
- name: Setup Node.js
31+
uses: actions/setup-node@v3
32+
with:
33+
node-version: 'lts/*'
34+
- name: Install dependencies
35+
run: npm clean-install
36+
- name: Verify the integrity of provenance attestations and registry signatures for installed dependencies
37+
run: npm audit signatures
38+
- name: Release
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
run: npx semantic-release

.hooks/commit-msg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env sh
2+
npx --no -- commitlint --edit $1

.hooks/post-checkout

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
printf '\npost-checkout hook\n\n'
6+
7+
prevHEAD=$1
8+
newHEAD=$2
9+
checkoutType=$3
10+
11+
[[ $checkoutType == 1 ]] && checkoutType='branch' ||
12+
checkoutType='file' ;
13+
14+
echo 'Checkout type: '$checkoutType
15+
echo ' prev HEAD: '`git name-rev --name-only $prevHEAD`
16+
echo ' new HEAD: '`git name-rev --name-only $newHEAD`
17+
18+
make clean

.hooks/pre-commit

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env sh
2+
3+
if [ -z "${CHECKS_RUN}" ]; then
4+
echo "Pre-commit checks will start as it is a manual commit"
5+
npx --no-install git-precommit-checks
6+
npx lint-staged --concurrent=false
7+
npx validate-branch-name
8+
else
9+
echo "Skipping Pre-commit checks as they already executed"
10+
fi

.releaserc.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"branches": [
3+
"main",
4+
{
5+
"name": "staging",
6+
"prerelease": true
7+
},
8+
"production"
9+
],
10+
"repositoryUrl": "https://github.com/steamicc/makecode-steami.git",
11+
"debug": "false",
12+
"plugins": [
13+
"@semantic-release/commit-analyzer",
14+
"@semantic-release/release-notes-generator",
15+
[
16+
"@semantic-release/changelog",
17+
{
18+
"changelogFile": "CHANGELOG.md",
19+
"changelogTitle": "# Semantic Versioning Changelog"
20+
}
21+
],
22+
[
23+
"@semantic-release/git",
24+
{
25+
"assets": ["package.json", "CHANGELOG.md"],
26+
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
27+
}
28+
],
29+
[
30+
"@semantic-release/github",
31+
{
32+
"assets": [
33+
{
34+
"path": "release/**"
35+
}
36+
]
37+
}
38+
]
39+
]
40+
}

.validate-branch-namerc.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
pattern: "^(main|staging|production)$|^(chores|feature|fix|docs)\/([0-9]){0,3}-([a-z0-9]+-)*[a-z0-9]+$|^release\/v([0-9]+)\.([0-9]+)\.([0-9]+)([a-z0-9-]*)$",
3+
errorMsg: "🤨 La branche que tu essaies de pusher ne respecte pas nos conventions, tu peux la renommer avec `git branch -m <nom-actuel> <nouveau-nom>`",
4+
}

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,12 @@ endef
121121
all : setup
122122

123123
.PHONY : setup
124-
setup : | _deepclean install-makecode-steami install-pxt install-pxt-common-packages install-pxt-steami install-pxt-steami-backend
124+
setup : | prepare _deepclean install-makecode-steami install-pxt install-pxt-common-packages install-pxt-steami install-pxt-steami-backend
125+
126+
.PHONY : prepare
127+
prepare :
128+
@echo "Install Git hooks"
129+
git config core.hooksPath .hooks
125130

126131
.PHONY : install-makecode-steami
127132
install-makecode-steami : node_modules/.package-lock.json package-lock.json

commitlint.config.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module.exports = {
2+
extends: ['@commitlint/config-conventional'],
3+
parserPreset: {
4+
parserOpts: {
5+
issuePrefixes: ['#'],
6+
},
7+
},
8+
rules: {
9+
'subject-case': [2, 'always', ['lower-case']],
10+
'scope-enum': [1, 'always', ['wip', 'configs', 'formatting', 'code', 'deployment', 'tests']],
11+
},
12+
};

git-precommit-checks.config.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
module.exports = {
2+
display: {
3+
notifications: true,
4+
offendingContent: true,
5+
rulesSummary: false,
6+
shortStats: true,
7+
verbose: false,
8+
},
9+
rules: [
10+
{
11+
message: 'Aurais-tu oublié de terminer certaines tâches ? Aurais-tu une issue à ouvrir pour traiter cette tache plus tard ?',
12+
nonBlocking: true,
13+
regex: /(?:FIXME|TODO)/,
14+
},
15+
{
16+
message: 'Tu as des marqueurs de conflits qui traînent dans ton code',
17+
regex: /^[<>|=]{4,}/m,
18+
},
19+
{
20+
message:
21+
'Arrêt du commit : tu as renseigné des choses qui ne doivent pas être commitées !',
22+
regex: /do not commit/i,
23+
},
24+
{
25+
filter: /\.js$/,
26+
message: '🤔 Hum ! N’as-tu pas oublié de retirer du "console.log(…)" ?',
27+
nonBlocking: true,
28+
regex: /^\s*console\.log/,
29+
},
30+
],
31+
}

0 commit comments

Comments
 (0)