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

Run Jellyfish Tests in parallel #2865

Merged
merged 8 commits into from
Mar 21, 2024
Merged

Conversation

canonbrother
Copy link
Contributor

@canonbrother canonbrother commented Mar 19, 2024

Summary

  • speed up jellyfish ci by running with 10 instances, from (approximately) 2 hrs to 40 (30+15) mins

@canonbrother canonbrother changed the title Chore: inspect jf ci Chore: Speed up jf ci Mar 19, 2024
@canonbrother canonbrother marked this pull request as ready for review March 19, 2024 07:47
@canonbrother canonbrother self-assigned this Mar 19, 2024
Copy link
Member

@sieniven sieniven left a comment

Choose a reason for hiding this comment

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

Am I missing something - I dont exactly see how running 10 instances of the same jellyfish test will speed up the CI runtime?

@canonbrother
Copy link
Contributor Author

canonbrother commented Mar 19, 2024

Am I missing something - I dont exactly see how running 10 instances of the same jellyfish test will speed up the CI runtime?

here for your reference about to compare the before/after of total duration
before https://github.com/DeFiCh/ain/actions/runs/8337022104
after https://github.com/DeFiCh/ain/actions/runs/8338085780/job/22817831027?pr=2865

@Jouzo
Copy link
Collaborator

Jouzo commented Mar 19, 2024

jest.sequencer.js


class CustomSequencer extends Sequencer {
  sort (tests) {
    // In CI, GitHub Actions tests are parallelized across multiple instance
    if (process.env.GH_INSTANCE_TOTAL) {
      const total = parseInt(process.env.GH_INSTANCE_TOTAL, 10)
      const index = parseInt(process.env.GH_INSTANCE_INDEX, 10)

      return ShuffleSeed.shuffle(tests, 'deterministic')
        .filter((_, i) => i % total === index)
    }

    return tests
  }
}

That's where the magic happens

Jouzo
Jouzo previously approved these changes Mar 19, 2024
Copy link
Member

@sieniven sieniven left a comment

Choose a reason for hiding this comment

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

If this is the case, we should then separate the docker build stage and then run the tests in 10 instances instead. Does not make sense to block 10 runners while building the same image on every instance.

@canonbrother canonbrother marked this pull request as draft March 19, 2024 08:16
@canonbrother canonbrother force-pushed the canonbrother/inspect-jf-ci branch 7 times, most recently from c90ec88 to ba61b5d Compare March 20, 2024 09:01
@canonbrother
Copy link
Contributor Author

sigh.. the workflow_run is not supported on PR

@canonbrother canonbrother force-pushed the canonbrother/inspect-jf-ci branch 3 times, most recently from b55f69d to 16e5cf6 Compare March 20, 2024 09:05
@canonbrother canonbrother marked this pull request as ready for review March 20, 2024 10:28
@Jouzo
Copy link
Collaborator

Jouzo commented Mar 20, 2024

Great improvements, thanks @canonbrother !

Jouzo
Jouzo previously approved these changes Mar 20, 2024
@prasannavl prasannavl changed the title Chore: Speed up jf ci Run Jellyfish Tests in parallel Mar 20, 2024
.github/workflows/tests-jellyfish.yml Outdated Show resolved Hide resolved
.github/workflows/tests-jellyfish.yml Outdated Show resolved Hide resolved
@canonbrother canonbrother force-pushed the canonbrother/inspect-jf-ci branch 11 times, most recently from 7fe321b to b00c099 Compare March 21, 2024 07:12
@canonbrother canonbrother force-pushed the canonbrother/inspect-jf-ci branch 2 times, most recently from 905585a to d7aa522 Compare March 21, 2024 07:32
@prasannavl prasannavl merged commit fe1a87d into master Mar 21, 2024
25 of 26 checks passed
@prasannavl prasannavl deleted the canonbrother/inspect-jf-ci branch March 21, 2024 09:17
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.

4 participants