test(integration): Add debug message on refresh failing #168
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Unit & integration tests | |
on: | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- '**.md' | |
schedule: | |
- cron: '25 02 * * THU' | |
workflow_dispatch: | |
inputs: | |
unit_tests: | |
type: boolean | |
description: Run Unit tests | |
default: true | |
integration_tests: | |
type: boolean | |
description: Run Integration tests | |
default: true | |
permissions: | |
contents: read | |
env: | |
# Allow ddev get to use a GitHub token to prevent rate limiting by tests | |
DDEV_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
jobs: | |
test-suite: | |
strategy: | |
fail-fast: false | |
matrix: | |
php-version: ['7.2','7.3','7.4','8.0','8.1', '8.2', '8.3'] | |
name: Unit and integration test | |
runs-on: ubuntu-latest | |
if: ${{ !contains(github.event.head_commit.message, 'chore(') }} | |
env: | |
EXTENSION_PATH: "my-code/remediation-engine" | |
steps: | |
- name: Install DDEV | |
# @see https://ddev.readthedocs.io/en/stable/#installationupgrade-script-linux-and-macos-armarm64-and-amd64-architectures | |
run: | | |
curl -fsSL https://apt.fury.io/drud/gpg.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/ddev.gpg > /dev/null | |
echo "deb [signed-by=/etc/apt/trusted.gpg.d/ddev.gpg] https://apt.fury.io/drud/ * *" | sudo tee /etc/apt/sources.list.d/ddev.list | |
sudo apt-get -q update | |
sudo apt-get -q -y install libnss3-tools ddev | |
mkcert -install | |
ddev config global --instrumentation-opt-in=false --omit-containers=ddev-ssh-agent | |
- name: Create empty PHP DDEV project | |
run: ddev config --project-type=php --project-name=remediation-engine --php-version=${{ matrix.php-version }} | |
- name: Add Redis, Memcached and Crowdsec | |
run: | | |
ddev get ddev/ddev-redis | |
ddev get ddev/ddev-memcached | |
# override redis.conf | |
ddev get julienloizelet/ddev-tools | |
ddev get julienloizelet/ddev-crowdsec-php | |
- name: Start DDEV | |
uses: nick-fields/retry@v3 | |
with: | |
timeout_minutes: 5 | |
max_attempts: 3 | |
shell: bash | |
command: ddev start | |
- name: Some DEBUG information | |
run: | | |
ddev --version | |
ddev exec php -v | |
ddev exec -s crowdsec cscli version | |
- name: Clone sources | |
uses: actions/checkout@v4 | |
with: | |
path: ${{env.EXTENSION_PATH}} | |
- name: Validate composer.json | |
run: | | |
ddev composer validate --strict --working-dir ./${{env.EXTENSION_PATH}} | |
- name: Install dependencies | |
run: | | |
ddev composer update --working-dir ./${{env.EXTENSION_PATH}} | |
- name: Prepare PHP UNIT tests | |
if: | | |
github.event.inputs.unit_tests == 'true' || | |
github.event_name == 'push' || | |
github.event_name == 'schedule' | |
run: | | |
ddev maxmind-download DEFAULT GeoLite2-City /var/www/html/${{env.EXTENSION_PATH}}/tests/geolocation | |
ddev maxmind-download DEFAULT GeoLite2-Country /var/www/html/${{env.EXTENSION_PATH}}/tests/geolocation | |
cd ${{env.EXTENSION_PATH}}/tests/geolocation | |
sha256sum -c GeoLite2-Country.tar.gz.sha256.txt | |
sha256sum -c GeoLite2-City.tar.gz.sha256.txt | |
tar -xf GeoLite2-Country.tar.gz | |
tar -xf GeoLite2-City.tar.gz | |
rm GeoLite2-Country.tar.gz GeoLite2-Country.tar.gz.sha256.txt GeoLite2-City.tar.gz GeoLite2-City.tar.gz.sha256.txt | |
- name: Run Unit tests | |
if: | | |
github.event.inputs.unit_tests == 'true' || | |
github.event_name == 'push' || | |
github.event_name == 'schedule' | |
run: ddev php ./${{env.EXTENSION_PATH}}/vendor/bin/phpunit --debug ./${{env.EXTENSION_PATH}}/tests/Unit --testdox | |
- name: Prepare integration tests | |
if: | | |
github.event.inputs.integration_tests == 'true' || | |
github.event_name == 'push' || | |
github.event_name == 'schedule' | |
run: | | |
echo -n "{\"machine_id\":\"${{ secrets.TEST_MACHINE_ID }}\"}" > ${{env.EXTENSION_PATH}}/tests/Integration/dev-machine-id.json | |
echo -n "{\"password\":\"${{ secrets.TEST_MACHINE_PWD }}\"}" > ${{env.EXTENSION_PATH}}/tests/Integration/dev-password.json | |
- name: Run Integration tests | |
if: | | |
github.event.inputs.integration_tests == 'true' || | |
github.event_name == 'push' || | |
github.event_name == 'schedule' | |
run: ddev php ./${{env.EXTENSION_PATH}}/vendor/bin/phpunit ./${{env.EXTENSION_PATH}}/tests/Integration --testdox |