diff --git a/.circleci/config.yml b/.circleci/config.yml index 9c8c599a..2e3956ab 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -4,7 +4,7 @@ version: 2.1 executors: deployer: docker: - - image: cimg/base:2020.12 + - image: cimg/base:current jobs: deploy-public-upstream: @@ -50,11 +50,15 @@ workflows: version: 2 deploy-public-upstream: jobs: + - check-commits: + filters: + branches: + only: + - release - deploy-public-upstream: + requires: + - check-commits filters: branches: only: - release - check-commits: - jobs: - - check-commits diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6ee5e523..1aae3a57 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,16 +1,22 @@ -name: CI +name: Lint and Test -on: [push] +on: + pull_request: + types: + - opened + - reopened + - synchronize + - ready_for_review jobs: build: runs-on: ubuntu-latest strategy: matrix: - php-version: ['7.4', '8.0', '8.1'] + php-version: ['8.0', '8.1', '8.2', '8.3'] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -31,7 +37,7 @@ jobs: run: composer validate --no-check-all - name: Install Composer dependencies - run: composer install --no-progress --prefer-dist --optimize-autoloader + run: composer update --no-progress --prefer-dist --optimize-autoloader - name: Run lints run: composer lint diff --git a/.github/workflows/composer-diff.yml b/.github/workflows/composer-diff.yml new file mode 100644 index 00000000..00e97e01 --- /dev/null +++ b/.github/workflows/composer-diff.yml @@ -0,0 +1,27 @@ +name: Composer Diff +on: + pull_request: + paths: + - 'composer.lock' +permissions: + pull-requests: write +jobs: + composer-diff: + name: Composer Diff + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Generate composer diff + id: composer_diff + uses: IonBazan/composer-diff-action@v1 + - uses: marocchino/sticky-pull-request-comment@v2 + if: ${{ steps.composer_diff.outputs.composer_diff_exit_code != 0 }} + with: + header: composer-diff + message: | + Composer Changes + + ${{ steps.composer_diff.outputs.composer_diff }} diff --git a/.github/workflows/sage-test.yml b/.github/workflows/sage-test.yml index d4e25b36..3e568bee 100644 --- a/.github/workflows/sage-test.yml +++ b/.github/workflows/sage-test.yml @@ -1,4 +1,7 @@ name: Sage Install Tests +permissions: + pull-requests: read + contents: read on: push: paths: @@ -14,14 +17,15 @@ jobs: run: shell: bash strategy: + fail-fast: false matrix: os: [ubuntu-latest, macos-latest] - php-version: [8.0, 8.1, 8.2, 8.3] + php-version: [8.1, 8.2, 8.3] steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install SSH keys - uses: webfactory/ssh-agent@v0.8.0 + uses: webfactory/ssh-agent@v0.9.0 with: ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} - name: Get and Set PR number @@ -35,6 +39,10 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-version }} + - name: Set up Node + uses: actions/setup-node@v4 + with: + node-version: current - name: Generate multidev name id: generate_name run: | @@ -94,7 +102,18 @@ jobs: echo "Deleting existing sage-test..." rm -rf web/app/themes/sage-test fi + echo "Checking for existing multidev..." + multidevs=$(terminus env:list wpcm-sage-install-tests --format=json --fields=id) + # Use jq to check if the key exists in the JSON + match_exists=$(echo "$json_output" | jq --arg id "$multidev_name" 'any(.[]; .id == $id)') + if [ "$match_exists" == "true" ]; then + echo "Environment $multidev_name exists." + terminus multidev:delete --delete-branch --yes wpcm-sage-install-tests.$multidev_name + else + echo "Environment $multidev_name does not exist." + fi terminus multidev:create wpcm-sage-install-tests.dev $multidev_name + terminus workflow:wait wpcm-sage-install-tests."$multidev_name" --quiet --max=15 echo "Checking out multidev..." git fetch --all git checkout $multidev_name @@ -113,7 +132,7 @@ jobs: - name: Install Composer Dependencies run: | cd ~/pantheon-local-copies/wpcm-sage-install-tests - composer install + composer update - name: Run Sage Install Script env: SAGENAME: sage-test @@ -133,7 +152,7 @@ jobs: if: always() run: | cd ~/pantheon-local-copies/wpcm-sage-install-tests - git fetch --tags origin # 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 diff --git a/.github/workflows/testing.yml b/.github/workflows/sync-default.yml similarity index 93% rename from .github/workflows/testing.yml rename to .github/workflows/sync-default.yml index 1ec08f79..548506b2 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/sync-default.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 token: ${{ secrets.GITHUB_TOKEN }} diff --git a/composer.json b/composer.json index d43a05bf..c816adc5 100644 --- a/composer.json +++ b/composer.json @@ -50,7 +50,7 @@ } ], "require": { - "php": ">=7.4", + "php": ">=8.0", "composer/installers": "^2.2", "vlucas/phpdotenv": "^5.5", "oscarotero/env": "^2.1", diff --git a/private/scripts/helpers.sh b/private/scripts/helpers.sh index 745f3c20..b48d5dc0 100755 --- a/private/scripts/helpers.sh +++ b/private/scripts/helpers.sh @@ -281,10 +281,14 @@ function update_php() { # Install sage and related dependencies. function install_sage_theme() { # Check if the directory $sagedir is empty. If it's not, bail. - echo "Checking if ${sagedir} is exists and if it's empty." + echo "Checking if ${sagedir} exists and if it's empty." if [ "$(ls -A "$sagedir")" ]; then echo "${red}Directory not empty!${normal}" + if [ "$is_ci" -eq 1 ]; then + echo "${yellow}Removing ${sagedir} for CI tests.${normal}" + rm -rf "$sagedir" + fi echo "Trying to install into ${sagedir}. Exiting." exit 1; fi