Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Batch building/compiling tests #2558

Merged
merged 6 commits into from
Jul 24, 2024
Merged

Batch building/compiling tests #2558

merged 6 commits into from
Jul 24, 2024

Conversation

AndreasArvidsson
Copy link
Member

We have to many tests in to many packages now. On windows I get The commandline is too long. Solving this by batching 50 tests at the time.

Checklist

  • [/] I have added tests
  • [/] I have updated the docs and cheatsheet
  • [/] I have not broken the cheatsheet

@AndreasArvidsson
Copy link
Member Author

@pokey Appears that mapfile doesn't work on the bash version used by default in macOS. Should we try this?
jitterbit/get-changed-files#15 (comment)

Copy link
Member

@pokey pokey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow this is some serious bash-foo. guessing chatgpt helped you here? 😅

@pokey
Copy link
Member

pokey commented Jul 24, 2024

looks like you'll need a different trick on mac tho; see CI 😕

@pokey
Copy link
Member

pokey commented Jul 24, 2024

@pokey Appears that mapfile doesn't work on the bash version used by default in macOS. Should we try this? jitterbit/get-changed-files#15 (comment)

hmm not sure. seems slightly strange to install new bash and overwrite default one. here's what chatgpt suggests:

#!/usr/bin/env bash
set -euo pipefail

# Initialize an empty array to hold the test files
TESTS=()

# Read the output of the find command into the TESTS array
while IFS= read -r file; do
    TESTS+=("$file")
done < <(find .. -name '*.test.ts')

BATCH_SIZE=50
SIZE=${#TESTS[@]}

for ((i = 0; i < SIZE; i += BATCH_SIZE)); do
    BATCH=("${TESTS[@]:i:BATCH_SIZE}")
    pnpm run build:base --outdir=dist --out-extension:.js=.cjs "${BATCH[@]}"
done

But I don't feel strongly; probably fine to use that bash upgrade trick?

@pokey
Copy link
Member

pokey commented Jul 24, 2024

alternately, you could rewrite it in typescript so it can be read by humans? 😅

@AndreasArvidsson
Copy link
Member Author

wow this is some serious bash-foo. guessing chatgpt helped you here? 😅

Maybe :D

@AndreasArvidsson
Copy link
Member Author

AndreasArvidsson commented Jul 24, 2024

alternately, you could rewrite it in typescript so it can be read by humans? 😅

Using esbuild js api?

I'm general for that, but then I think we should probably switch all our esbuild to that and that should probably be a separate pull request. I will try the suggestion above first.

@pokey
Copy link
Member

pokey commented Jul 24, 2024

actually i think xargs can do this for us:

#!/usr/bin/env bash
set -euo pipefail

find .. -name '*.test.ts' | xargs -n 50 pnpm run build:base --outdir=dist --out-extension:.js=.cjs

@AndreasArvidsson
Copy link
Member Author

Oh xargs was one of the things I tested first, but I couldn't get it to work. I must have done something weird because this looks fine :)

@AndreasArvidsson AndreasArvidsson added this pull request to the merge queue Jul 24, 2024
Merged via the queue into main with commit ae60577 Jul 24, 2024
15 checks passed
@AndreasArvidsson AndreasArvidsson deleted the batchBuildTests branch July 24, 2024 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants