mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 12:55:26 +01:00
Merge pull request #10424 from kkmuffme/use-pr-branch-name-for-randomization-of-tests
use branch name to randomize tests to ensure test dependencies will error
This commit is contained in:
commit
f9f8bacdf1
1
.github/workflows/ci.yml
vendored
1
.github/workflows/ci.yml
vendored
@ -136,6 +136,7 @@ jobs:
|
||||
CHUNK_COUNT: "${{ matrix.count }}"
|
||||
CHUNK_NUMBER: "${{ matrix.chunk }}"
|
||||
PARALLEL_PROCESSES: 5
|
||||
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
|
||||
|
||||
steps:
|
||||
- name: Set up PHP
|
||||
|
@ -3,13 +3,15 @@
|
||||
set -eu
|
||||
|
||||
function get_seeded_random() {
|
||||
openssl enc -aes-256-ctr -pass pass:"vimeo/psalm" -nosalt </dev/zero 2>/dev/null
|
||||
local -r branch_name="$1"
|
||||
openssl enc -aes-256-ctr -pass pass:"$branch_name" -nosalt </dev/zero 2>/dev/null
|
||||
}
|
||||
|
||||
function run {
|
||||
local -r chunk_count="$1"
|
||||
local -r chunk_number="$2"
|
||||
local -r parallel_processes="$3"
|
||||
local -r branch_name="$4"
|
||||
|
||||
local -r phpunit_cmd='
|
||||
echo "::group::{}";
|
||||
@ -23,7 +25,7 @@ exit "$exit_code"'
|
||||
|
||||
mkdir -p build/parallel/ build/phpunit/logs/
|
||||
|
||||
find tests -name '*Test.php' | shuf --random-source=<(get_seeded_random) > build/tests_all
|
||||
find tests -name '*Test.php' | shuf --random-source=<(get_seeded_random "$branch_name") > build/tests_all
|
||||
# split incorrectly splits the lines by byte size, which means that the number of tests per file are as evenly distributed as possible
|
||||
#split --number="l/$chunk_number/$chunk_count" build/tests_all > build/tests_split
|
||||
local -r lines=$(wc -l <build/tests_all)
|
||||
@ -47,5 +49,6 @@ exit "$exit_code"'
|
||||
if [ -z "${CHUNK_COUNT:-}" ]; then echo "Did not find env var CHUNK_COUNT."; exit 1; fi
|
||||
if [ -z "${CHUNK_NUMBER:-}" ]; then echo "Did not find env var CHUNK_NUMBER."; exit 1; fi
|
||||
if [ -z "${PARALLEL_PROCESSES:-}" ]; then echo "Did not find env var PARALLEL_PROCESSES."; exit 1; fi
|
||||
if [ -z "${BRANCH_NAME:-}" ]; then echo "Did not find env var BRANCH_NAME."; exit 1; fi
|
||||
|
||||
run "$CHUNK_COUNT" "$CHUNK_NUMBER" "$PARALLEL_PROCESSES"
|
||||
run "$CHUNK_COUNT" "$CHUNK_NUMBER" "$PARALLEL_PROCESSES" "$BRANCH_NAME"
|
||||
|
Loading…
Reference in New Issue
Block a user