|
| 1 | +name: Behat CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ master, main ] |
| 6 | + pull_request: |
| 7 | + workflow_dispatch: |
| 8 | + schedule: |
| 9 | + # Nightly at 00:00 UTC (CircleCI had cron "0 0 * * *" with branch filter=master) |
| 10 | + - cron: "0 0 * * *" |
| 11 | + |
| 12 | +permissions: |
| 13 | + contents: read |
| 14 | + actions: write |
| 15 | + |
| 16 | +jobs: |
| 17 | + test-behat: |
| 18 | + # Run nightly only on master (schedule can't filter branches directly) |
| 19 | + if: github.event_name != 'schedule' || github.ref == 'refs/heads/master' |
| 20 | + |
| 21 | + runs-on: ubuntu-latest |
| 22 | + |
| 23 | + env: |
| 24 | + RUN_NUM: ${{ github.run_number }} |
| 25 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 26 | + TERMINUS_TOKEN: ${{ secrets.TERMINUS_TOKEN }} |
| 27 | + |
| 28 | + steps: |
| 29 | + - name: Checkout |
| 30 | + uses: actions/checkout@v5 |
| 31 | + with: |
| 32 | + fetch-depth: 0 |
| 33 | + |
| 34 | + - name: Cache dependencies |
| 35 | + uses: actions/cache@v3 |
| 36 | + with: |
| 37 | + path: ~/vendor |
| 38 | + key: test-lint-dependencies-{{ checksum "composer.json" }} |
| 39 | + restore-keys: test-lint-dependencies-{{ checksum "composer.json" }} |
| 40 | + |
| 41 | + - name: Install dependencies |
| 42 | + run: composer install -n --prefer-dist |
| 43 | + |
| 44 | + - name: Run PHP Lint |
| 45 | + run: composer phpcs |
| 46 | + |
| 47 | + - name: Install Terminus |
| 48 | + uses: pantheon-systems/terminus-github-actions@v1 |
| 49 | + with: |
| 50 | + pantheon-machine-token: ${{ secrets.TERMINUS_TOKEN }} |
| 51 | + |
| 52 | + - name: Validate Readme Spacing |
| 53 | + uses: pantheon-systems/validate-readme-spacing@v1 |
| 54 | + |
| 55 | + - name: Install Subversion |
| 56 | + run: | |
| 57 | + sudo apt-get update |
| 58 | + sudo apt-get install subversion |
| 59 | +
|
| 60 | + - name: Generate admin password |
| 61 | + run: echo $(openssl rand -hex 8) > /tmp/WORDPRESS_ADMIN_PASSWORD |
| 62 | + |
| 63 | + - name: Export env |
| 64 | + run: | |
| 65 | + { |
| 66 | + echo "TERMINUS_ENV=ci-${RUN_NUM}" |
| 67 | + echo "TERMINUS_SITE=wp-native-php-sessions" |
| 68 | + echo "SITE_ENV=wp-native-php-sessions.ci-${RUN_NUM}" |
| 69 | + echo "WORDPRESS_ADMIN_USERNAME=pantheon" |
| 70 | + echo "WORDPRESS_ADMIN_EMAIL=no-reply@getpantheon.com" |
| 71 | + echo "WORDPRESS_ADMIN_PASSWORD=$(cat /tmp/WORDPRESS_ADMIN_PASSWORD)" |
| 72 | + } >> "$GITHUB_ENV" |
| 73 | +
|
| 74 | + - name: Force SSH to ignore host keys |
| 75 | + run: echo "GIT_SSH_COMMAND=ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" >> $GITHUB_ENV |
| 76 | + |
| 77 | + - name: Install SSH key |
| 78 | + uses: webfactory/ssh-agent@v0.7.0 |
| 79 | + with: |
| 80 | + ssh-private-key: ${{ secrets.SITE_OWNER_SSH_PRIVATE_KEY }} |
| 81 | + |
| 82 | + - name: Configure Composer GitHub OAuth (optional) |
| 83 | + if: env.GITHUB_TOKEN != '' |
| 84 | + run: | |
| 85 | + echo "Setting Composer GitHub OAuth token (output suppressed)" |
| 86 | + { composer config -g github-oauth.github.com "$GITHUB_TOKEN"; } &>/dev/null |
| 87 | +
|
| 88 | + - name: Validate fixture version |
| 89 | + uses: jazzsequence/action-validate-plugin-version@v1 |
| 90 | + with: |
| 91 | + branch: ${{ github.head_ref }} |
| 92 | + dry-run: 'true' |
| 93 | + |
| 94 | + - name: Behat prepare |
| 95 | + run: | |
| 96 | + terminus auth:login --machine-token=$TERMINUS_TOKEN |
| 97 | + terminus self:plugin:install terminus-build-tools-plugin |
| 98 | + ./bin/behat-prepare.sh |
| 99 | +
|
| 100 | + - name: Behat tests (strict) |
| 101 | + run: ./bin/behat-test.sh --strict |
| 102 | + |
| 103 | + - name: Cleanup (always) |
| 104 | + if: always() |
| 105 | + run: ./bin/behat-cleanup.sh |
0 commit comments