tests.yml 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. name: Automated tests
  2. on:
  3. push:
  4. branches: [ edge ]
  5. pull_request:
  6. branches: [ edge ]
  7. jobs:
  8. tests:
  9. # https://github.com/actions/virtual-environments
  10. runs-on: ubuntu-latest
  11. steps:
  12. - name: Git checkout source code
  13. uses: actions/checkout@v2
  14. # Composer tests
  15. - name: Check PHP syntax
  16. run: composer run-script php-lint
  17. - name: Check PHTML syntax
  18. run: composer run-script phtml-lint
  19. - name: Check translations syntax
  20. run: composer run-script translations && git diff --exit-code
  21. - name: Use Composer cache
  22. id: composer-cache
  23. uses: actions/cache@v2
  24. with:
  25. path: vendor
  26. key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
  27. restore-keys: |
  28. ${{ runner.os }}-php-
  29. - name: Run Composer install
  30. run: composer install --prefer-dist --no-progress
  31. if: steps.composer-cache.outputs.cache-hit != 'true'
  32. - name: Run PHP unit tests
  33. run: composer run-script phpunit
  34. - name: PHP_CodeSniffer
  35. run: composer run-script phpcs
  36. # NPM tests
  37. - name: Uses Node.js
  38. uses: actions/setup-node@v2
  39. with:
  40. # https://nodejs.org/en/about/releases/
  41. node-version: '14'
  42. cache: 'npm'
  43. - run: npm install
  44. - name: Check JavaScript syntax
  45. run: npm run --silent eslint
  46. - name: Check Markdown syntax
  47. run: npm run --silent markdownlint
  48. - name: Check Right-to-left CSS
  49. run: npm run --silent rtlcss && git diff --exit-code
  50. - name: Check CSS syntax
  51. run: npm run --silent stylelint
  52. # Shell tests
  53. - name: Use shell cache
  54. id: shell-cache
  55. uses: actions/cache@v2
  56. with:
  57. path: bin
  58. key: ${{ runner.os }}-bin-shfmt@v3.4.0c-hadolint@v2.7.0
  59. - name: Add ./bin/ to $PATH
  60. run: mkdir -p bin/ && echo "${PWD}/bin" >> $GITHUB_PATH
  61. - name: Setup Go
  62. if: steps.shell-cache.outputs.cache-hit != 'true'
  63. # Multiple Go versions are pre-installed but the default 1.15 is too old
  64. # https://github.com/actions/setup-go
  65. uses: actions/setup-go@v2
  66. with:
  67. go-version: '1.17'
  68. - name: Install shfmt
  69. if: steps.shell-cache.outputs.cache-hit != 'true'
  70. run: GOBIN=${PWD}/bin/ go install mvdan.cc/sh/v3/cmd/shfmt@v3.4.0
  71. - name: Check shell script syntax
  72. # shellcheck is pre-installed https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-README.md
  73. run: ./tests/shellchecks.sh
  74. - name: Install hadolint
  75. if: steps.shell-cache.outputs.cache-hit != 'true'
  76. run: curl -sL -o ./bin/hadolint "https://github.com/hadolint/hadolint/releases/download/v2.7.0/hadolint-$(uname -s)-$(uname -m)" && chmod 700 ./bin/hadolint
  77. - name: Check Dockerfile syntax
  78. run: find . -name 'Dockerfile*' -print0 | xargs -0 -n1 ./bin/hadolint --failure-threshold warning