tests.yml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. name: Automated tests
  2. on:
  3. push:
  4. branches: [ edge ]
  5. pull_request:
  6. branches: [ edge ]
  7. permissions:
  8. contents: read
  9. jobs:
  10. tests:
  11. # https://github.com/actions/virtual-environments
  12. runs-on: ubuntu-26.04
  13. steps:
  14. - name: Git checkout source code
  15. uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
  16. # Composer tests
  17. - name: Check PHP syntax
  18. run: composer run-script php-lint
  19. - name: Check PHTML syntax
  20. run: composer run-script phtml-lint
  21. - name: Check translations syntax
  22. run: composer run-script translations && git diff --exit-code
  23. - name: Use Composer cache
  24. id: composer-cache
  25. uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
  26. with:
  27. path: vendor
  28. key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
  29. restore-keys: |
  30. ${{ runner.os }}-php-
  31. - name: Run Composer install
  32. run: composer install --prefer-dist --no-progress
  33. if: steps.composer-cache.outputs.cache-hit != 'true'
  34. - name: Run PHP unit tests
  35. run: composer run-script phpunit -- --no-progress
  36. - name: PHP_CodeSniffer
  37. run: composer run-script phpcs
  38. - name: PHPStan
  39. run: composer run-script phpstan -- --no-progress
  40. # - name: PHPStan Next
  41. # run: composer run-script phpstan-next -- --no-progress
  42. # NPM tests
  43. - name: Uses Node.js
  44. uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
  45. with:
  46. # https://nodejs.org/en/about/previous-releases
  47. node-version: lts/*
  48. cache: npm
  49. - run: npm ci
  50. - name: Check JavaScript syntax
  51. run: npm run --silent eslint
  52. - name: Check Markdown syntax
  53. run: npm run --silent markdownlint
  54. - name: Check CSS syntax
  55. run: npm run --silent stylelint
  56. - name: Check Right-to-left CSS
  57. run: npm run --silent rtlcss && git diff --exit-code
  58. # Shell tests
  59. - name: Use shell cache
  60. id: shell-cache
  61. uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
  62. with:
  63. path: bin
  64. key: ${{ runner.os }}-bin-shfmt@v3.8.0-hadolint@v2.15.1-typos@v1.49.0
  65. - name: Add ./bin/ to $PATH
  66. run: mkdir -p bin/ && echo "${PWD}/bin" >> $GITHUB_PATH
  67. - name: Install shfmt
  68. if: steps.shell-cache.outputs.cache-hit != 'true'
  69. run: GOBIN=${PWD}/bin/ go install mvdan.cc/sh/v3/cmd/shfmt@v3.8.0
  70. - name: Check shell script syntax
  71. # shellcheck is pre-installed https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2204-Readme.md
  72. run: ./tests/shellchecks.sh
  73. - name: Install hadolint
  74. if: steps.shell-cache.outputs.cache-hit != 'true'
  75. run: |
  76. curl -sL -o ./bin/hadolint "https://github.com/hadolint/hadolint/releases/download/v2.15.1/hadolint-linux-x86_64" &&
  77. echo 'c7187db94eeeeca956519a6af171adc31453941a1e777961f6e680f697c8c507 ./bin/hadolint' | sha256sum -c - &&
  78. chmod 700 ./bin/hadolint
  79. - name: Check Dockerfile syntax
  80. run: find . -name 'Dockerfile*' -print0 | xargs -0 -n1 ./bin/hadolint --failure-threshold warning
  81. - name: Install typos
  82. if: steps.shell-cache.outputs.cache-hit != 'true'
  83. run: |
  84. cd bin ;
  85. wget -q 'https://github.com/crate-ci/typos/releases/download/v1.49.0/typos-v1.49.0-x86_64-unknown-linux-musl.tar.gz' &&
  86. echo '48bd2d58e02ce713b8c0f1aa239e68ee4f7d8c551013135806e6aed3938d9e10 typos-v1.49.0-x86_64-unknown-linux-musl.tar.gz' | sha256sum -c - &&
  87. tar -xvf *.tar.gz './typos' &&
  88. chmod +x typos &&
  89. rm *.tar.gz ;
  90. cd ..
  91. - name: Check spelling
  92. run: bin/typos