Skip to content

Commit

Permalink
Update Sage Test workflow (#121)
Browse files Browse the repository at this point in the history
* if there is no pr number, set pr_num to rel

* use brackets for multidev_name vars

* move workflow to pull_request instead of push

* apply the upstream updates to the multisite
this is happening inside a matrix so it will break if another run updates the upstream before the current one finishes

* don't echo empty string

* remove stray "

* apply upstream updates as a step outside the matrix

* get pr number from pull_request event

* update fallback logic

* use run number instead of pr

* use new install terminus action
  • Loading branch information
jazzsequence committed Jul 31, 2024
1 parent e8c0d25 commit 25d4dfe
Showing 1 changed file with 44 additions and 20 deletions.
64 changes: 44 additions & 20 deletions .github/workflows/sage-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,45 @@ permissions:
pull-requests: read
contents: read
on:
push:
pull_request:
paths:
- '.github/workflows/sage-test.yml'
- 'private/scripts/**'
types: [opened, synchronize, reopened, ready_for_review]
jobs:
apply_upstream_updates:
name: Apply Upstream Updates
runs-on: ubuntu-latest
env:
TERM: xterm-256color
defaults:
run:
shell: bash
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install SSH keys
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Get latest Terminus release
uses: pantheon-systems/action-terminus-install@v1
with:
os: ${{ matrix.os }}
- name: Validate Pantheon Host Key
run: |
echo "Host *.drush.in HostKeyAlgorithms +ssh-rsa" >> ~/.ssh/config
echo "Host *.drush.in PubkeyAcceptedKeyTypes +ssh-rsa" >> ~/.ssh/config
echo "StrictHostKeyChecking no" >> ~/.ssh/config
- name: Log into Terminus
run: |
terminus auth:login --machine-token=${{ secrets.TERMINUS_TOKEN }}
terminus upstream:updates:apply wpcm-sage-install-tests
test:
name: Sage Install Tests
env:
TERM: xterm-256color
needs: apply_upstream_updates
runs-on: ${{ matrix.os }}
defaults:
run:
Expand All @@ -31,8 +61,12 @@ jobs:
- name: Get and Set PR number
id: pr
run: |
pr_num=$(gh pr view --json number -q .number || echo "")
echo "PR_NUM=$pr_num" >> $GITHUB_ENV
pr_num=${{ github.run_number }}
if [ "${pr_num}" == "" ]; then
echo "PR_NUM=rel" >> $GITHUB_ENV
else
echo "PR_NUM=${pr_num}" >> $GITHUB_ENV
fi
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Setup PHP
Expand Down Expand Up @@ -67,27 +101,17 @@ jobs:
echo "Generated multidev name: $multidev_name"
echo "multidev_name=$multidev_name" >> $GITHUB_ENV
- name: Get latest Terminus release
run: |
if [[ "${{ matrix.os }}" == "macos-latest" ]]; then
echo "☕ Installing Terminus on macOS from Homebrew..."
brew install pantheon-systems/external/terminus
else
echo "💻 Installing Terminus from phar on Linux..."
curl -L "https://github.com/pantheon-systems/terminus/releases/latest/download/terminus.phar" -o terminus
chmod +x terminus
sudo mv terminus /usr/local/bin/
fi
# Test that terminus works...
terminus --version
uses: pantheon-systems/action-terminus-install@v1
with:
os: ${{ matrix.os }}
- name: Validate Pantheon Host Key
run: |
echo "Host *.drush.in HostKeyAlgorithms +ssh-rsa" >> ~/.ssh/config
echo "Host *.drush.in PubkeyAcceptedKeyTypes +ssh-rsa" >> ~/.ssh/config
echo "StrictHostKeyChecking no" >> ~/.ssh/config
- name: Log into Terminus and Check for updates
- name: Log into Terminus
run: |
terminus auth:login --machine-token=${{ secrets.TERMINUS_TOKEN }}
terminus upstream:updates:apply wpcm-sage-install-tests.dev --accept-upstream
- name: Clone site and create multidev
run: |
echo "Cloning site..."
Expand Down Expand Up @@ -147,12 +171,12 @@ jobs:
echo "✅ Sage Install Script passed!"
- name: Delete multidev
if: always()
run: terminus multidev:delete --delete-branch --yes wpcm-sage-install-tests.$multidev_name
run: terminus multidev:delete --delete-branch --yes "wpcm-sage-install-tests.${multidev_name}"
- name: Delete the multidev build artifact
if: always()
run: |
cd ~/pantheon-local-copies/wpcm-sage-install-tests
# Allow these to fail.
git fetch --tags origin || true
git tag -d pantheon_build_artifacts_$multidev_name || true
git push origin --delete pantheon_build_artifacts_$multidev_name || true
git tag -d "pantheon_build_artifacts_${multidev_name}" || true
git push origin --delete "pantheon_build_artifacts_${multidev_name}" || true

0 comments on commit 25d4dfe

Please sign in to comment.