aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2021-10-24 17:25:41 +0200
committerGravatar GitHub <noreply@github.com> 2021-10-24 17:25:41 +0200
commit9416f45dd9178039f8ce0e5a7d7328922d2d7695 (patch)
treeb96e637953fab571ed55d7ea275a14fcf1855c88
parent07e00c7681e5fd9e680cba75125b166b96a96198 (diff)
GitHub Actions CI optimisation (#3929)
Efforts to reduce the resources used by CI: * Only one git checkout * Exclusion of irrelevant directories for several commands * Fix some rtlcss warnings * Move some commands from tests.yml to composer.json to make them reusasble * Initial efforts to take avantage of all that from `make` (help welcome)
-rw-r--r--.eslintignore1
-rw-r--r--.github/workflows/tests.yml34
-rw-r--r--.jshintignore3
-rw-r--r--.markdownlintignore2
-rw-r--r--.stylelintignore3
-rw-r--r--Makefile33
-rw-r--r--composer.json8
-rw-r--r--package.json5
8 files changed, 67 insertions, 22 deletions
diff --git a/.eslintignore b/.eslintignore
index 4af5f2ccf..a3264ebd0 100644
--- a/.eslintignore
+++ b/.eslintignore
@@ -1,3 +1,4 @@
*.min.js
node_modules/
p/scripts/vendor/
+vendor/
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index daa91465d..25295ebd1 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -8,21 +8,24 @@ on:
jobs:
- composer:
+ tests:
# https://github.com/actions/virtual-environments
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v2
+ - name: Git checkout source code
+ uses: actions/checkout@v2
+
+ # Composer tests
- name: Check PHP syntax
- run: find . -name '*.php' -print0 | xargs -0 -n1 -P4 php -l 1>/dev/null
+ run: composer run-script php-lint
- name: Check PHTML syntax
- run: find . -name '*.phtml' -print0 | xargs -0 -n1 -P4 php -l 1>/dev/null
+ run: composer run-script phtml-lint
- name: Check translations syntax
- run: cli/manipulate.translation.php -a format && git diff --exit-code
+ run: composer run-script translations && git diff --exit-code
- name: Use Composer cache
id: composer-cache
@@ -33,17 +36,17 @@ jobs:
restore-keys: |
${{ runner.os }}-php-
- - run: composer install --prefer-dist --no-progress
+ - name: Run Composer install
+ run: composer install --prefer-dist --no-progress
if: steps.composer-cache.outputs.cache-hit != 'true'
- - name: Run PHP tests
- run: composer run-script test
+ - name: Run PHP unit tests
+ run: composer run-script phpunit
+ - name: PHP_CodeSniffer
+ run: composer run-script phpcs
- npm:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v2
+ # NPM tests
- name: Uses Node.js
uses: actions/setup-node@v2
@@ -66,11 +69,7 @@ jobs:
- name: Check CSS syntax
run: npm run stylelint
-
- shell:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v2
+ # Shell tests
- name: Use shell cache
id: shell-cache
@@ -83,6 +82,7 @@ jobs:
run: mkdir -p bin/ && echo "${PWD}/bin" >> $GITHUB_PATH
- name: Setup Go
+ if: steps.shell-cache.outputs.cache-hit != 'true'
# Multiple Go versions are pre-installed but the default 1.15 is too old
# https://github.com/actions/setup-go
uses: actions/setup-go@v2
diff --git a/.jshintignore b/.jshintignore
index b8a497857..21b0fd2eb 100644
--- a/.jshintignore
+++ b/.jshintignore
@@ -1,3 +1,4 @@
-node_modules
+node_modules/
p/scripts/bcrypt.min.js
p/scripts/vendor/
+vendor/
diff --git a/.markdownlintignore b/.markdownlintignore
index c2658d7d1..771399b60 100644
--- a/.markdownlintignore
+++ b/.markdownlintignore
@@ -1 +1,3 @@
node_modules/
+p/scripts/vendor/
+vendor/
diff --git a/.stylelintignore b/.stylelintignore
index 402ba0702..56613503b 100644
--- a/.stylelintignore
+++ b/.stylelintignore
@@ -1,3 +1,6 @@
+node_modules/
+p/scripts/vendor/
+vendor/
# ignore SASS-generated CSS
p/themes/Ansum/*.css
p/themes/Mapco/*.css
diff --git a/Makefile b/Makefile
index 72352ff42..adf30cad1 100644
--- a/Makefile
+++ b/Makefile
@@ -159,7 +159,7 @@ endif
###########
.PHONY: rtl
rtl: ## Generate RTL CSS files
- rtlcss -d p/themes && find . -type f -name '*.rtl.rtl.css' -delete
+ rtlcss -d p/themes/ && find p/themes/ -type f -name '*.rtl.rtl.css' -delete
.PHONY: pot
pot: ## Generate POT templates for docs
@@ -169,6 +169,37 @@ pot: ## Generate POT templates for docs
refresh: ## Refresh feeds by fetching new messages
@$(PHP) ./app/actualize_script.php
+###############################
+## New commands aligned on CI #
+## Work in progress #
+###############################
+
+# TODO: Add composer install
+.PHONY: composer-test
+composer-test:
+ composer run-script test
+
+.PHONY: composer-fix
+composer-fix:
+ composer run-script fix
+
+# TODO: Add npm install
+.PHONY: npm-test
+npm-test:
+ npm test
+
+.PHONY: npm-fix
+npm-fix:
+ npm run fix
+
+# TODO: Add shellcheck, shfmt, hadolint
+.PHONY: test-all
+test-all: composer-test npm-test
+
+.PHONY: fix-all
+fix-all: composer-fix npm-fix
+
+
##########
## HELP ##
##########
diff --git a/composer.json b/composer.json
index c39915caf..5590b24cf 100644
--- a/composer.json
+++ b/composer.json
@@ -24,14 +24,20 @@
"squizlabs/php_codesniffer": "^3.6"
},
"scripts": {
- "phpcs": "phpcs . -p -s",
+ "php-lint": "find . -type d -name 'vendor' -prune -o -name '*.php' -print0 | xargs -0 -n1 -P4 php -l 1>/dev/null",
+ "phtml-lint": "find . -type d -name 'vendor' -prune -o -name '*.phtml' -print0 | xargs -0 -n1 -P4 php -l 1>/dev/null",
+ "phpcs": "phpcs . -s",
"phpcbf": "phpcbf . -p -s",
"phpunit": "phpunit --bootstrap ./tests/bootstrap.php --verbose ./tests",
+ "translations": "cli/manipulate.translation.php -a format",
"test": [
+ "@php-lint",
+ "@phtml-lint",
"@phpunit",
"@phpcs"
],
"fix": [
+ "@translations",
"@phpcbf"
]
}
diff --git a/package.json b/package.json
index 8a25eb278..35884d900 100644
--- a/package.json
+++ b/package.json
@@ -23,7 +23,7 @@
"eslint_fix": "eslint --fix --ext .js .",
"markdownlint": "markdownlint '**/*.md'",
"markdownlint_fix": "markdownlint --fix '**/*.md'",
- "rtlcss": "rtlcss -d p/themes && find . -type f -name '*.rtl.rtl.css' -delete",
+ "rtlcss": "rtlcss -d p/themes/ && find p/themes/ -type f -name '*.rtl.rtl.css' -delete",
"stylelint": "stylelint '**/*.css' && stylelint --syntax scss '**/*.scss'",
"stylelint_fix": "stylelint --fix '**/*.css' && stylelint --fix --syntax scss '**/*.scss'",
"test": "npm run eslint && npm run stylelint && npm run markdownlint",
@@ -41,5 +41,6 @@
"stylelint-config-recommended-scss": "^4.3.0",
"stylelint-order": "^4.1.0",
"stylelint-scss": "^3.21.0"
- }
+ },
+ "rtlcssConfig": {}
}