diff --git a/.github/workflows/filter.yml b/.github/workflows/filter.yml index 96959ca81..751e47080 100644 --- a/.github/workflows/filter.yml +++ b/.github/workflows/filter.yml @@ -31,8 +31,8 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 - ref: ${{ github.head_ref }} - repository: ${{ github.repository }} + ref: ${{ github.event.pull_request.head.sha }} + repository: ${{ github.event.pull_request.head.repo.full_name }} persist-credentials: false - name: Find Updated Packages and crates id: filter @@ -40,6 +40,10 @@ jobs: CRATE_DIRS="" PACKAGE_DIRS="" + echo "The head ref is ${{ github.head_ref }}" + echo "The last five commits messages are $(git log -5 --pretty=%B)" + echo "name of current branch is ${{ github.ref }}" + # echo the base ref base_ref=${{ github.base_ref }} if [ -z "$base_ref" ] @@ -52,6 +56,7 @@ jobs: # Get the comparison point in the repo comparison_point="origin/${base_ref}" echo "The comparison point is $comparison_point" + echo "The changed files are $(git diff --name-only ${comparison_point}...)" for changed_file in $(git diff --name-only ${comparison_point}...) do @@ -64,13 +69,14 @@ jobs: continue fi - # Check if the changed file is a Cargo.toml or pyproject.toml file - if [ "${file_name}" == *"Cargo.toml"* ] | [ "${file_name}" == *"pyproject.toml"* ] + # Check if the changed file is a Cargo.toml + if [ "${file_name}" == *"Cargo.toml"* ] then + echo "Found a crate in $pkg_dir" # Check that the version is a dev version echo "Checking for dev version in $pkg_dir" - if [ $(cat $pkg_dir/VERSION) != *"dev"* ] + if [ ! -f $pkg_dir/VERSION ] && [ $(cat $pkg_dir/VERSION) != *"dev"* ] then msg="${pkg_dir} does not have a dev version" if [ ${{ inputs.ignore-missing-dev }} ] @@ -82,10 +88,33 @@ jobs: fi # If the package directory string contains the substring "crates", add it to the CRATE_DIRS string - if [ "$pkg_dir" =~ "crates"* ] + if [ "$pkg_dir" == *"crates"* ] then CRATE_DIRS="$CRATE_DIRS ${pkg_dir}" - else + fi + fi + + # Check if the changed file is a pyproject.toml + if [ "${file_name}" == *"pyproject.toml"* ] + then + echo "Found a package in $pkg_dir" + + # Check that the version is a dev version + echo "Checking for dev version in $pkg_dir" + if [ $(cat $pkg_dir/VERSION) != *"dev"* ] + then + msg="${pkg_dir} does not have a dev version" + if [ ${{ inputs.ignore-missing-dev }} ] + then + echo "::warning::${msg}" + else + echo "::error::${msg}" && exit 1 + fi + fi + + # If the package directory string contains the substring "python", add it to the PACKAGE_DIRS string + if [ "$pkg_dir" == *"python"* ] + then PACKAGE_DIRS="$PACKAGE_DIRS ${pkg_dir}" fi fi