1+ name : Run Tests
2+
3+ # When to run tests.
4+ on :
5+ pull_request :
6+ types :
7+ - opened
8+ - synchronize
9+ push :
10+ branches :
11+ - main
12+
13+ jobs :
14+ tests :
15+ # Name.
16+ name : PHP ${{ matrix.php-versions }}
17+
18+ # Virtual Environment to use.
19+ # @see: https://github.com/actions/virtual-environments
20+ runs-on : ubuntu-latest
21+
22+ # Defines PHP Versions matrix to run tests on
23+ strategy :
24+ matrix :
25+ php-versions : [ '7.4', '8.0', '8.1', '8.2' ]
26+
27+ # Steps to install, configure and run tests
28+ steps :
29+ # Checkout (copy) this repository's Plugin to this VM.
30+ - name : Checkout Code
31+ uses : actions/checkout@v3
32+
33+ # Install PHP version
34+ - name : Install PHP
35+ uses : shivammathur/setup-php@v2
36+ with :
37+ php-version : ${{ matrix.php-versions }}
38+ coverage : none
39+
40+ # Write any secrets, such as API keys, to the .env.dist.testing file now.
41+ # Make sure your committed .env.dist.testing file ends with a newline.
42+ # The formatting of the contents to include a blank newline is deliberate.
43+ - name : Define GitHub Secrets in .env.dist.testing
44+ uses :
DamianReeves/[email protected] 45+ with :
46+ path : .env.dist.testing
47+ contents : |
48+
49+ CONVERTKIT_API_KEY=${{ secrets.CONVERTKIT_API_KEY }}
50+ CONVERTKIT_API_SECRET=${{ secrets.CONVERTKIT_API_SECRET }}
51+ CONVERTKIT_API_KEY_NO_DATA=${{ secrets.CONVERTKIT_API_KEY_NO_DATA }}
52+ CONVERTKIT_API_SECRET_NO_DATA=${{ secrets.CONVERTKIT_API_SECRET_NO_DATA }}
53+ write-mode : append
54+
55+ # Rename .env.dist.testing to .env, so PHPUnit reads it for tests.
56+ - name : Rename .env.dist.testing to .env
57+ run : mv .env.dist.testing .env
58+
59+ # Installs PHPUnit, PHP CodeSniffer and anything else needed to run tests.
60+ - name : Run Composer
61+ run : composer update
62+
63+ # Generate autoloader
64+ - name : Build PHP Autoloader
65+ run : composer dump-autoload
66+
67+ # Run Coding Standards on Tests.
68+ - name : Run Coding Standards on Tests
69+ run : php vendor/bin/phpcs --standard=phpcs.tests.xml
70+
71+ # Run PHPUnit Tests.
72+ - name : Run PHPUnit Tests
73+ run : vendor/bin/phpunit --verbose --stop-on-failure
0 commit comments