Skip to content

Commit

Permalink
Re-create .env file in test jobs after workspace extraction
Browse files Browse the repository at this point in the history
- Add steps in run_php_74_unit_tests and run_php_80_unit_tests to ensure $HOME/tooling/docker-unit-tests/.env exists after workspace extraction.
- Export ENV_FILE to point to the .env file before running the docker unit tests.
- This guarantees that the script's source command has a valid filename, fixing the "No such file or directory" error.
  • Loading branch information
zackkatz committed Feb 17, 2025
1 parent 15d66fc commit 873cb5a
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- name: Clone GV Tooling
run: gh repo clone GravityKit/Tooling $HOME/tooling

# Ensure the docker-unit-tests directory exists and create the .env file there.
# Create .env file in docker-unit-tests folder after cloning
- name: Create .env file in docker-unit-tests if missing
run: |
mkdir -p "$HOME/tooling/docker-unit-tests"
Expand Down Expand Up @@ -109,6 +109,18 @@ jobs:
rsync -a /tmp/workspace/ $HOME/
fi
# Re-create the .env file in docker-unit-tests after extraction (in case it was overwritten)
- name: Ensure .env file in docker-unit-tests exists
run: |
mkdir -p "$HOME/tooling/docker-unit-tests"
if [ ! -f "$HOME/tooling/docker-unit-tests/.env" ]; then
echo "PLUGIN_DIR=$HOME" > "$HOME/tooling/docker-unit-tests/.env"
echo "WP_LATEST_TESTS_DIR=./wordpress-latest-tests-lib" >> "$HOME/tooling/docker-unit-tests/.env"
echo "PHPUNIT_DIR=./phpunit" >> "$HOME/tooling/docker-unit-tests/.env"
echo "GF_PLUGIN_DIR=./gravityforms" >> "$HOME/tooling/docker-unit-tests/.env"
echo "GH_AUTH_TOKEN=${{ secrets.GH_ACCESS_TOKEN }}" >> "$HOME/tooling/docker-unit-tests/.env"
fi
- name: Run PHP 7.4 Unit Tests
run: |
export ENV_FILE="$HOME/tooling/docker-unit-tests/.env"
Expand All @@ -134,6 +146,18 @@ jobs:
rsync -a /tmp/workspace/ $HOME/
fi
# Re-create the .env file in docker-unit-tests after extraction
- name: Ensure .env file in docker-unit-tests exists
run: |
mkdir -p "$HOME/tooling/docker-unit-tests"
if [ ! -f "$HOME/tooling/docker-unit-tests/.env" ]; then
echo "PLUGIN_DIR=$HOME" > "$HOME/tooling/docker-unit-tests/.env"
echo "WP_LATEST_TESTS_DIR=./wordpress-latest-tests-lib" >> "$HOME/tooling/docker-unit-tests/.env"
echo "PHPUNIT_DIR=./phpunit" >> "$HOME/tooling/docker-unit-tests/.env"
echo "GF_PLUGIN_DIR=./gravityforms" >> "$HOME/tooling/docker-unit-tests/.env"
echo "GH_AUTH_TOKEN=${{ secrets.GH_ACCESS_TOKEN }}" >> "$HOME/tooling/docker-unit-tests/.env"
fi
- name: Run PHP 8.0 Unit Tests
run: |
export ENV_FILE="$HOME/tooling/docker-unit-tests/.env"
Expand Down

0 comments on commit 873cb5a

Please sign in to comment.