Skip to content
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
24 changes: 24 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
tsconfigRootDir: __dirname,
sourceType: 'module',
},
plugins: ['@typescript-eslint/eslint-plugin'],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
],
root: true,
env: {
node: true,
},
ignorePatterns: ['.eslintrc.js', 'commitlint.config.js'],
rules: {
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
};
56 changes: 56 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Release
on:
push:
branches:
- main
- staging
- production

pull_request:
branches:
- main

permissions:
contents: read # for checkout

jobs:
release:
name: Release
runs-on: ubuntu-latest
container:
image: letssteam/makecode-toolchain:latest
options: --user 1001 --security-opt no-new-privileges
permissions:
contents: write # to be able to publish a GitHub release
issues: write # to be able to comment on released issues
pull-requests: write # to be able to comment on released pull requests
id-token: write # to enable use of OIDC for npm provenance
strategy:
matrix:
node-version: [20.x]
steps:
- name: Cache node modules
id: cache-npm
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- uses: actions/checkout@v4
- run: npm run setup
- run: npm run ci
- name: Verify the integrity of provenance attestations and registry signatures for installed dependencies
run: npm audit signatures
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx semantic-release
2 changes: 2 additions & 0 deletions .hooks/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env sh
npx --no -- commitlint --edit $1
18 changes: 18 additions & 0 deletions .hooks/post-checkout
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

set -e

printf '\npost-checkout hook\n\n'

prevHEAD=$1
newHEAD=$2
checkoutType=$3

[[ $checkoutType == 1 ]] && checkoutType='branch' ||
checkoutType='file' ;

echo 'Checkout type: '$checkoutType
echo ' prev HEAD: '`git name-rev --name-only $prevHEAD`
echo ' new HEAD: '`git name-rev --name-only $newHEAD`

make clean
10 changes: 10 additions & 0 deletions .hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env sh

if [ -z "${CHECKS_RUN}" ]; then
echo "Pre-commit checks will start as it is a manual commit"
npx --no-install git-precommit-checks
npx lint-staged --concurrent=false
npx validate-branch-name
else
echo "Skipping Pre-commit checks as they already executed"
fi
19 changes: 19 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"branches": [
"main",
{
"name": "staging",
"prerelease": true
},
"production"
],
"repositoryUrl": "https://github.com/steamicc/makecode-steami.git",
"debug": "false",
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/npm",
"@semantic-release/git",
"@semantic-release/github"
]
}
4 changes: 4 additions & 0 deletions .validate-branch-namerc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
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-]*)$",
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>`",
}
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,12 @@ endef
all : setup

.PHONY : setup
setup : | _deepclean install-makecode-steami install-pxt install-pxt-common-packages install-pxt-steami install-pxt-steami-backend
setup : | prepare _deepclean install-makecode-steami install-pxt install-pxt-common-packages install-pxt-steami install-pxt-steami-backend

.PHONY : prepare
prepare :
@echo "Install Git hooks"
git config core.hooksPath .hooks

.PHONY : install-makecode-steami
install-makecode-steami : node_modules/.package-lock.json package-lock.json
Expand Down
12 changes: 12 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
parserPreset: {
parserOpts: {
issuePrefixes: ['#'],
},
},
rules: {
'subject-case': [2, 'always', ['lower-case']],
'scope-enum': [1, 'always', ['wip', 'configs', 'formatting', 'code', 'deployment', 'tests']],
},
};
31 changes: 31 additions & 0 deletions git-precommit-checks.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module.exports = {
display: {
notifications: true,
offendingContent: true,
rulesSummary: false,
shortStats: true,
verbose: false,
},
rules: [
{
message: 'Aurais-tu oublié de terminer certaines tâches ? Aurais-tu une issue à ouvrir pour traiter cette tache plus tard ?',
nonBlocking: true,
regex: /(?:FIXME|TODO)/,
},
{
message: 'Tu as des marqueurs de conflits qui traînent dans ton code',
regex: /^[<>|=]{4,}/m,
},
{
message:
'Arrêt du commit : tu as renseigné des choses qui ne doivent pas être commitées !',
regex: /do not commit/i,
},
{
filter: /\.js$/,
message: '🤔 Hum ! N’as-tu pas oublié de retirer du "console.log(…)" ?',
nonBlocking: true,
regex: /^\s*console\.log/,
},
],
}
33 changes: 30 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
"setup": "make setup",
"ci": "make ci",
"package": "make package",
"staticserve": "make staticserve"
"staticserve": "make staticserve",
"prepare": "make prepare",
"commit:checks": "npx --no-install git-precommit-checks && npx lint-staged && npx validate-branch-name && git-cz",
"prepare-commit": "cross-env CHECKS_RUN=1 npm run commit:checks"
},
"repository": {
"type": "git",
Expand All @@ -21,10 +24,34 @@
"url": "https://github.com/steamicc/makecode-steami/issues"
},
"dependencies": {
"eslint": "^9.7.0",
"pxt": "^0.5.1"
},
"devDependencies": {
"nodemon": "^3.1.4"
"@commitlint/cli": "^19.5.0",
"@commitlint/config-conventional": "^19.5.0",
"@commitlint/cz-commitlint": "^19.5.0",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/commit-analyzer": "^13.0.0",
"@semantic-release/git": "^10.0.1",
"@semantic-release/github": "^11.0.0",
"commitizen": "^4.3.1",
"cross-env": "^7.0.3",
"eslint": "^9.12.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"git-precommit-checks": "^3.1.0",
"nodemon": "^3.1.4",
"prettier": "^3.3.3",
"semantic-release": "^24.1.2",
"validate-branch-name": "^1.3.1"
},
"lint-staged": {
"*.js, *.json, *.css": "prettier",
"*.ts": "eslint"
},
"config": {
"commitizen": {
"path": "@commitlint/cz-commitlint"
}
}
}