From 6db87ef52b6811a457bc9e3585716818fb0dfddb Mon Sep 17 00:00:00 2001 From: John Hooks Date: Tue, 12 Dec 2023 20:57:50 -0800 Subject: [PATCH] ci: add code standard workflow --- .distignore | 13 +++++++-- .github/workflows/coding-standards.yml | 40 ++++++++++++++++++++++++++ .github/workflows/test-suite.yml | 3 +- .stylelintignore | 13 +++++++++ bin/init-pipeline.sh | 1 - composer.json | 15 ++++++---- package.json | 8 ++++-- tsconfig.json | 1 - 8 files changed, 80 insertions(+), 14 deletions(-) create mode 100644 .github/workflows/coding-standards.yml create mode 100644 .stylelintignore diff --git a/.distignore b/.distignore index 6bec07c..1091565 100644 --- a/.distignore +++ b/.distignore @@ -1,20 +1,30 @@ .git .github .idea +.husky +.vscode bin -node_modules +client tests +node_modules +vendor .composer .distignore +.editorconfig .env +.env.example .eslintignore .eslintrc.json .gitattributes .gitignore .npmrc .nvmrc +.php-cs-fixer.cache .php-cs-fixer.php .php-cs-fixer.dist.php +.prettierignore +.prettierrc.js +.stylelintignore babel.config.cjs codeception.yml codeception.dist.yml @@ -30,5 +40,4 @@ README.md tsconfig.eslint.json tsconfig.json webpack.config.cjs -vendor $GITHUB_WORKSPACE diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml new file mode 100644 index 0000000..2255744 --- /dev/null +++ b/.github/workflows/coding-standards.yml @@ -0,0 +1,40 @@ +name: Coding Standards + +on: + pull_request: + branches: [main, epic/*] + workflow_dispatch: + +jobs: + lint: + name: Check Coding Standards + runs-on: ubuntu-latest + environment: testing + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install dependenices + uses: ./.github/actions/install + + - name: Generate testing files + shell: bash + run: | + envsubst < tests/.env.example > tests/.env + php vendor/bin/codecept build + + - name: Lint PHP + shell: bash + run: | + composer run-script lint + composer run-script analyze + + - name: Lint JavaScript + shell: bash + run: | + npm run lint:js + npm run check + + - name: Lint Styles + shell: bash + run: npm run lint:css diff --git a/.github/workflows/test-suite.yml b/.github/workflows/test-suite.yml index 14b9c72..261579f 100644 --- a/.github/workflows/test-suite.yml +++ b/.github/workflows/test-suite.yml @@ -18,8 +18,7 @@ jobs: - name: Setup environment shell: bash - run: | - envsubst < tests/.env.example > tests/.env + run: envsubst < tests/.env.example > tests/.env - name: Cache Docker images. uses: ScribeMD/docker-cache@0.3.6 diff --git a/.stylelintignore b/.stylelintignore new file mode 100644 index 0000000..5b408c5 --- /dev/null +++ b/.stylelintignore @@ -0,0 +1,13 @@ +.cache +build +build-module +build-types + +tests +coverage + +vendor +vendor-prod +node_modules + +tests/_wordpress diff --git a/bin/init-pipeline.sh b/bin/init-pipeline.sh index 87fbe4b..f2f0e28 100755 --- a/bin/init-pipeline.sh +++ b/bin/init-pipeline.sh @@ -1,4 +1,3 @@ #!/usr/bin/env bash ./bin/test-up.sh -./bin/wait-for-it.sh http://localhost:$WORDPRESS_LOCALHOST_PORT diff --git a/composer.json b/composer.json index 60826d9..a5b48cc 100644 --- a/composer.json +++ b/composer.json @@ -75,16 +75,19 @@ "@strauss" ], "strauss": [ - "vendor/bin/strauss" + "@php vendor/bin/strauss" ], - "test": [ - "vendor/bin/codecept run acceptance,unit" + "test:acceptance": [ + "@php vendor/bin/codecept run acceptance" ], - "test:analyze": [ - "vendor/bin/phpstan analyze --memory-limit=4G --ansi" + "analyze": [ + "@php vendor/bin/phpstan analyse --memory-limit=4G --no-progress --no-interaction --ansi" + ], + "lint": [ + "@php vendor/bin/php-cs-fixer check --config=.php-cs-fixer.dist.php --ansi" ], "lint:fix": [ - "vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php --ansi" + "@php vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php --ansi" ] }, "scripts-descriptions": { diff --git a/package.json b/package.json index 3cd0e34..bac3960 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,8 @@ "start": "wp-scripts start", "format": "wp-scripts format ./client/src", "lint:css": "wp-scripts lint-style", - "lint:js": "eslint --ext .js,.jsx,.ts,.tsx .", + "lint:js": "eslint --ext .js,.jsx,.cjs,.mjs,.ts,.tsx .", + "check": "tsc -b", "test": "jest --silent=false --coverage", "prepare": "husky install" }, @@ -65,6 +66,9 @@ "extends": [ "@wordpress/stylelint-config", "@wordpress/stylelint-config/scss" - ] + ], + "rules": { + "indentation": 2 + } } } diff --git a/tsconfig.json b/tsconfig.json index 2dd801f..9316c23 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,7 +5,6 @@ "outDir": "./build-types", "strict": true, - "declarationMap": true, "resolveJsonModule": true, "forceConsistentCasingInFileNames": true, "pretty": true,