diff --git a/.github/workflows/check_diff.yml b/.github/workflows/check_diff.yml deleted file mode 100644 index ac78c637370..00000000000 --- a/.github/workflows/check_diff.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: PR analysis - -on: - workflow_call: - outputs: - skip: { type: boolean, description: "Whether to skip dependent CI checks" } - pull_request: - -concurrency: - group: ${{ github.ref }}-${{ github.head_ref }}-checkdiff - cancel-in-progress: true - -jobs: - check_diff: - name: Check files changed - runs-on: ubuntu-20.04 - env: - BASE_REF: ${{ github.event.pull_request.base.ref }} - HEAD_REF: ${{ github.event.pull_request.head.ref }} - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Add forked repository as remote - run: | - git remote add fork ${{ github.event.pull_request.head.repo.clone_url }} - - name: Fetch base branch from main repository - run: | - git fetch origin ${BASE_REF} - - name: Fetch head branch from forked repository - run: | - git fetch fork ${HEAD_REF} - - name: Get files changed - run: | - git diff --name-only --diff-filter=ACMRTUXB origin/${BASE_REF}..fork/${HEAD_REF} > check_diff.txt - - name: Check files changed - id: check - run: | - if grep -v -E "^(Docs|\.github)/|\.azure-pipelines\.yml$" check_diff.txt; then - echo "skip=false" - echo "skip=false" >> ${GITHUB_OUTPUT} - else - echo "skip=true" - echo "skip=true" >> ${GITHUB_OUTPUT} - fi - echo "GITHUB_OUTPUT = ${GITHUB_OUTPUT}" - outputs: - skip: ${{ steps.check.outputs.skip }} diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 2e7754f3054..6ebbba50b55 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -8,23 +8,37 @@ concurrency: cancel-in-progress: true jobs: + + skip_checks: + name: Skip checks? + runs-on: macos-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Run PR analysis script + run: | + .github/workflows/scripts/check_diff.sh \ + ${{ github.event.pull_request.head.ref }} \ + ${{ github.event.pull_request.base.ref }} \ + ${{ github.event.pull_request.head.repo.clone_url }} + outputs: + skip: ${{ env.SKIP_CHECKS }} + build_appleclang: name: AppleClang runs-on: macos-latest + needs: skip_checks + if: ${{ github.event.pull_request.draft == false && needs.skip_checks.outputs.skip == false }} steps: - - name: Run PR analysis - uses: ./.github/workflows/pr-analysis.yml - id: pr_analysis - name: Checkout code - if: ${{ github.event.pull_request.draft == false && steps.pr_analysis.outputs.skip == "false" }} uses: actions/checkout@v4 - name: Install Python - if: ${{ github.event.pull_request.draft == false && steps.pr_analysis.outputs.skip == "false" }} uses: actions/setup-python@v5 with: python-version: '3.x' - name: Install brew dependencies - if: ${{ github.event.pull_request.draft == false && steps.pr_analysis.outputs.skip == "false" }} run: | set +e brew unlink gcc @@ -41,14 +55,12 @@ jobs: brew tap openpmd/openpmd brew install openpmd-api - name: Install pip dependencies - if: ${{ github.event.pull_request.draft == false && steps.pr_analysis.outputs.skip == "false" }} run: | python3 -m pip install --upgrade pip python3 -m pip install --upgrade build packaging setuptools wheel python3 -m pip install --upgrade mpi4py python3 -m pip install --upgrade -r Regression/requirements.txt - name: CCache Cache - if: ${{ github.event.pull_request.draft == false && steps.pr_analysis.outputs.skip == "false" }} uses: actions/cache@v4 with: path: ~/Library/Caches/ccache @@ -56,7 +68,6 @@ jobs: restore-keys: | ccache-${{ github.workflow }}-${{ github.job }}-git- - name: Build WarpX - if: ${{ github.event.pull_request.draft == false && steps.pr_analysis.outputs.skip == "false" }} run: | export CCACHE_COMPRESS=1 export CCACHE_COMPRESSLEVEL=10 @@ -86,7 +97,6 @@ jobs: du -hs ~/Library/Caches/ccache ccache -s - name: Run pywarpx - if: ${{ github.event.pull_request.draft == false && steps.pr_analysis.outputs.skip == "false" }} run: | export OMP_NUM_THREADS=1 diff --git a/.github/workflows/scripts/check_diff.sh b/.github/workflows/scripts/check_diff.sh new file mode 100755 index 00000000000..32af0fa8d6d --- /dev/null +++ b/.github/workflows/scripts/check_diff.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +set -o nounset +set -o errexit +set -o pipefail + +# Parse command line arguments +head_ref=${1} +base_ref=${2} +clone_url=${3} + +# Set paths to ignore +paths_ignore="^(Docs|\.github)/|\.azure-pipelines\.yml$" + +# Add forked repository as remote +git remote add fork ${clone_url} + +# Fetch base branch from main repository +git fetch origin ${base_ref} + +# Fetch head branch from forked repository +git fetch fork ${head_ref} + +# Save output of git diff to inspect files changed +git diff --name-only --diff-filter=ACMRTUXB origin/${base_ref}..fork/${head_ref} > check_diff.txt + +# Set skip variable after inspecting files changed +skip=$(grep -v -E "${paths_ignore}" check_diff.txt) + +# Set an environment variable based on the output +if [ -z "$skip" ]; then + echo "SKIP_CHECKS=true" >> $GITHUB_ENV +else + echo "SKIP_CHECKS=false" >> $GITHUB_ENV +fi