Update current score when PR merged (#4464)

This commit is contained in:
merwanehamadi
2023-05-29 19:30:41 -07:00
committed by GitHub
parent d34b8a2b61
commit ba8046753e
4 changed files with 22 additions and 6 deletions

View File

@@ -119,6 +119,7 @@ jobs:
- name: Run pytest tests with coverage
run: |
pytest -n auto --cov=autogpt --cov-report term-missing --cov-branch --cov-report xml --cov-report term
python tests/integration/challenges/utils/build_current_score.py
env:
CI: true
PROXY: ${{ secrets.PROXY }}
@@ -131,11 +132,20 @@ jobs:
- name: Update cassette submodule to push target if push event
if: ${{ github.event_name == 'push' }}
run: |
cd tests/Auto-GPT-test-cassettes
current_branch=$(echo ${{ github.ref }} | sed -e "s/refs\/heads\///g")
git fetch origin $current_branch
git config --global user.name "Auto-GPT-Bot"
git config --global user.email "github-bot@agpt.co"
git add tests/integration/challenges/current_score.json
if ! git diff-index --quiet HEAD; then
git commit -m "Update current score"
git push origin HEAD:refs/heads/$current_branch
else
echo "The current score didn't change."
fi
cd tests/Auto-GPT-test-cassettes
git fetch origin $current_branch
git add .
# Check if there are any changes
@@ -150,7 +160,7 @@ jobs:
git commit -m "Update submodule reference"
git push origin HEAD:refs/heads/$current_branch
else
echo "No changes to commit"
echo "No cassettes changes to commit"
exit 0
fi

View File

@@ -9,6 +9,7 @@ class Challenge:
name: str,
category: str,
max_level: int,
is_new_challenge: bool,
max_level_beaten: Optional[int],
level_to_run: Optional[int] = None,
) -> None:
@@ -19,3 +20,4 @@ class Challenge:
self.succeeded = False
self.skipped = False
self.level_to_run = level_to_run
self.is_new_challenge = is_new_challenge

View File

@@ -48,7 +48,7 @@ def challenge(func: Callable[..., Any]) -> Callable[..., None]:
pytest.skip("This test has not been unlocked yet.")
if not challenge.succeeded:
if Challenge.BEAT_CHALLENGES:
if Challenge.BEAT_CHALLENGES or challenge.is_new_challenge:
# xfail
pytest.xfail("Challenge failed")
raise AssertionError("Challenge failed")

View File

@@ -13,13 +13,13 @@ def create_challenge(
level_to_run: Optional[int] = None,
) -> Challenge:
challenge_category, challenge_name = get_challenge_identifiers(func)
is_new_challenge = challenge_name not in current_score.get(challenge_category, {})
max_level = get_max_level(current_score, challenge_category, challenge_name)
max_level_beaten = get_max_level_beaten(
current_score, challenge_category, challenge_name
)
level_to_run = get_level_to_run(
is_beat_challenges, level_to_run, max_level, max_level_beaten
is_beat_challenges, level_to_run, max_level, max_level_beaten, is_new_challenge
)
return Challenge(
@@ -28,6 +28,7 @@ def create_challenge(
max_level=max_level,
max_level_beaten=max_level_beaten,
level_to_run=level_to_run,
is_new_challenge=is_new_challenge,
)
@@ -36,7 +37,10 @@ def get_level_to_run(
level_to_run: Optional[int],
max_level: int,
max_level_beaten: Optional[int],
is_new_challenge: bool,
) -> Optional[int]:
if is_new_challenge:
return 1
if level_to_run is not None:
if level_to_run > max_level:
raise ValueError(