tests.yml 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. - name: PHPStan
  37. run: composer run-script phpstan
  38. # NPM tests
  39. - name: Uses Node.js
  40. uses: actions/setup-node@v2
  41. with:
  42. # https://nodejs.org/en/about/releases/
  43. node-version: '14'
  44. cache: 'npm'
  45. - run: npm install
  46. - name: Check JavaScript syntax
  47. run: npm run --silent eslint
  48. - name: Check Markdown syntax
  49. run: npm run --silent markdownlint
  50. - name: Check Right-to-left CSS
  51. run: npm run --silent rtlcss && git diff --exit-code
  52. - name: Check CSS syntax
  53. run: npm run --silent stylelint
  54. # Shell tests
  55. - name: Use shell cache
  56. id: shell-cache
  57. uses: actions/cache@v2
  58. with:
  59. path: bin
  60. key: ${{ runner.os }}-bin-shfmt@v3.4.0c-hadolint@v2.7.0-typos@v1.3.3
  61. - name: Add ./bin/ to $PATH
  62. run: mkdir -p bin/ && echo "${PWD}/bin" >> $GITHUB_PATH
  63. - name: Setup Go
  64. if: steps.shell-cache.outputs.cache-hit != 'true'
  65. # Multiple Go versions are pre-installed but the default 1.15 is too old
  66. # https://github.com/actions/setup-go
  67. uses: actions/setup-go@v2
  68. with:
  69. go-version: '1.17'
  70. - name: Install shfmt
  71. if: steps.shell-cache.outputs.cache-hit != 'true'
  72. run: GOBIN=${PWD}/bin/ go install mvdan.cc/sh/v3/cmd/shfmt@v3.4.0
  73. - name: Check shell script syntax
  74. # shellcheck is pre-installed https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-README.md
  75. run: ./tests/shellchecks.sh
  76. - name: Install hadolint
  77. if: steps.shell-cache.outputs.cache-hit != 'true'
  78. 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
  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.3.3/typos-v1.3.3-x86_64-unknown-linux-musl.tar.gz' &&
  86. tar -xvf *.tar.gz './typos' &&
  87. chmod +x typos &&
  88. rm *.tar.gz ;
  89. cd ..
  90. - name: Check spelling
  91. run: bin/typos