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

speed up #190

Open
kmyk opened this issue Mar 5, 2020 · 4 comments
Open

speed up #190

kmyk opened this issue Mar 5, 2020 · 4 comments

Comments

@kmyk
Copy link
Member

kmyk commented Mar 5, 2020

現在は、大量のファイルを変更してしまったときや大量のファイルに依存されているファイルを変更してしまったとき、 GITHUB_TOKEN の timeout 問題 #51 のために途中で verify が打ち切られてしまう。空コミットをタイミングよく push するのは簡単に自動化できるとはいえ、あまり良くない。

選択肢はふたつ:

  1. 再帰的にやる: GH_PAT を使えば再帰的に GitHub Action を起動できるのでこれを使う。ただし、バグで無限ループしたりしたときがやばいし、時間はかかる
  2. 並列で高速化する: 20 並列で 1 時間回せばさすがに終わる。理想だけど、GitHub Action に詳しくならないと実装ができない
@lrvideckis
Copy link

Just wanted to comment on another solution: cron job: basically run oj-verify all every 30 minutes.

https://github.com/lrvideckis/programming_team_code/blob/main/.github/workflows/run_tests_scheduled.yml

This was https://codeforces.com/profile/camc 's idea

@lrvideckis
Copy link

just wanted to comment another solution: github CLI allows running a CI action https://cli.github.com/manual/gh_workflow_run

so you can write a script to pull the verify file, and if un-run tests, start the CI action to run more tests

script1.sh:

#!/bin/bash
# ** glob now searches any number of levels
shopt -s globstar

# so that paths match up for comm command (otherwise you need basename)
cd ..

echo "total number of tests:"
find . -type f -name "*.test.cpp" | wc --lines

echo "number of tests which have run:"
grep --count "test.cpp" .verify-helper/timestamps.remote.json

echo "tests which have *not* run:"
! comm -23 --check-order <(
	find . -type f -name "*.test.cpp" |
		sort |
		uniq
) <(
	grep --only-matching '".*test.cpp"' .verify-helper/timestamps.remote.json |
		tr -d '"' |
		sort |
		uniq
) |
	grep .

script2.sh:

#!/bin/bash
# ** glob now searches any number of levels
shopt -s globstar


echo "pulling dev"
git pull

while ! ./script1.sh; do
	echo "not all tests ran; starting CI to run more tests"
	gh workflow run 'CI' --ref dev
	echo "sleeping for 15 minutes"
	sleep 15m
	echo "pulling dev"
	git pull
done

@lrvideckis
Copy link

lrvideckis commented Feb 21, 2024

.yml file:

on: [push, workflow_dispatch]

jobs:
  library_checker_aizu:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v1
    - name: Set up Python
      uses: actions/setup-python@v1
    - name: Install dependencies
      run: pip3 install -U online-judge-verify-helper
    - name: Set up Rust (1.42.0)
      uses: actions-rs/toolchain@v1
      with:
        toolchain: 1.42.0-x86_64-unknown-linux-gnu
        default: true
        profile: minimal
    # required by cargo-udeps
    - name: Set up Rust (nightly)
      uses: actions-rs/toolchain@v1
      with:
        toolchain: nightly-x86_64-unknown-linux-gnu
        default: true
        profile: minimal
    - name: Run tests
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        YUKICODER_TOKEN: ${{ secrets.YUKICODER_TOKEN }}
        GH_PAT: ${{ secrets.GH_PAT }}
      run: oj-verify all --tle 20

full example

https://github.com/programming-team-code/programming_team_code/blob/dev/.github/workflows/programming_team_code_ci.yml

https://github.com/programming-team-code/programming_team_code/blob/dev/tests/scripts/print_which_tests_havent_run.sh

https://github.com/programming-team-code/programming_team_code/blob/dev/tests/scripts/finish_running_tests.sh

@lrvideckis
Copy link

today I learned a github CI job can run for 6 hours https://docs.github.com/en/actions/learn-github-actions/usage-limits-billing-and-administration#usage-limits and noting you can set --timeout I actually don't see how this is a problem

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

No branches or pull requests

2 participants