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

Gio/test ats update #13

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 34 additions & 8 deletions .github/workflows/codecov_ats.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,22 @@ jobs:
token: ${{ github.token }}
filters: .github/file-filters.yml
coverage-ats:
# Temporary test
if: needs.files-changed.outputs.backend == 'true'
#if: needs.files-changed.outputs.backend == 'true'
needs: files-changed
timeout-minutes: 40
runs-on: ubuntu-latest
# Map a step output to a job output
outputs:
ATS_TESTS_TO_RUN: ${{ steps.label_analysis.outputs.ATS_TESTS_TO_RUN }}
ATS_TESTS_TO_SKIP: ${{ steps.label_analysis.outputs.ATS_TESTS_TO_SKIP }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
fetch-depth: 2
- name: Set up Python 3.10.10
uses: actions/setup-python@v4
with:
python-version: "3.10.10"
# We need the setup to collect the list of tests properly
- name: Setup sentry env
uses: ./.github/actions/setup-sentry
id: setup
Expand All @@ -60,7 +63,7 @@ jobs:
pg-version: 14
- name: Download Codecov CLI
run: |
pip install --extra-index-url https://pypi.org/simple --no-cache-dir pytest codecov-cli
pip install --extra-index-url https://pypi.org/simple --no-cache-dir codecov-cli
# Creates the commit and report objects in codecov
- name: Codecov startup
run: |
Expand All @@ -80,13 +83,36 @@ jobs:
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
CODECOV_STATIC_TOKEN: ${{ secrets.CODECOV_STATIC_TOKEN }}
# Run label analysis IN DRY MODE (no tests will actually run)
# Run label analysis in dry mode to get the list of tests to run
# The base commit will be the parent commit (apparently commits on master don't exist in codecov)
- name: Label Analysis
id: label_analysis
continue-on-error: true
run: |
BASE_COMMIT=$(git merge-base ${{ github.sha }}^ origin/master)
set +e
BASE_COMMIT=$(git rev-parse ${{ github.sha }}^)
echo $BASE_COMMIT
codecovcli --codecov-yml-path=codecov.yml label-analysis --dry-run --token=${CODECOV_STATIC_TOKEN} --base-sha=${BASE_COMMIT}
output=$(codecovcli --codecov-yml-path=codecov.yml label-analysis --dry-run --token=${CODECOV_STATIC_TOKEN} --base-sha=${BASE_COMMIT})
if [ $? -eq 0 ]
then
ATS_TESTS_TO_RUN=$(echo $output | grep -e ATS_TESTS_TO_RUN= | tr -d "ATS_TESTS_TO_RUN=")
ATS_TESTS_TO_SKIP=$(echo $output | grep -e ATS_TESTS_TO_SKIP= | tr -d "ATS_TESTS_TO_SKIP=")

echo "ATS_TESTS_TO_RUN=$ATS_TESTS_TO_RUN" >> "$GITHUB_OUTPUT"
echo "ATS_TESTS_TO_SKIP=$ATS_TESTS_TO_SKIP" >> "$GITHUB_OUTPUT"

test_to_run_count=$(echo $ATS_TESTS_TO_RUN | awk '{print gsub("[ \t]",""); exit}')
test_to_skip_count=$(echo $ATS_TESTS_TO_SKIP | awk '{print gsub("[ \t]",""); exit}')
echo "Selected $test_to_run_count / $total_tests_count tests to run" >> $GITHUB_STEP_SUMMARY
else
echo "ATS failed. Can't get list of tests to run. Fallback to all tests"
echo "ATS failed. Can't get list of tests to run. Fallback to all tests" >> $GITHUB_STEP_SUMMARY
echo "ATS_TESTS_TO_RUN=--cov-context=test" >> "$GITHUB_OUTPUT"
echo "ATS_TESTS_TO_SKIP=" >> "$GITHUB_OUTPUT"
fi

env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
CODECOV_STATIC_TOKEN: ${{ secrets.CODECOV_STATIC_TOKEN }}
# The actual running of tests would come here, after the labels are available
# Something like pytest <options> $ATS_TESTS_TO_RUN
13 changes: 10 additions & 3 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# Setting coverage targets per flag
coverage:
status:
project:
default: false
project: "off"
patch:
default: false
frontend:
# codecov will not fail status checks for master
only_pulls: true
Expand Down Expand Up @@ -77,6 +75,15 @@ comment:
require_base: true # must have a base report to post
require_head: true # must have a head report to post

flag_management:
individual_flags:
- name: smart-tests
carryforward: true
carryforward_mode: "labels"
statuses:
- type: "patch"
enabled: false

cli:
# This would be used when uploading the ats results
# But we will not be doing that yet
Expand Down
1 change: 1 addition & 0 deletions src/sentry/api/helpers/mobile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


def get_readable_device_name(device: str) -> str:
print("Change")

Check warning on line 6 in src/sentry/api/helpers/mobile.py

View check run for this annotation

Codecov / codecov/patch

src/sentry/api/helpers/mobile.py#L6

Added line #L6 was not covered by tests
if device in IOS_MODELS:
return IOS_MODELS[device]
if device in ANDROID_MODELS:
Expand Down
Loading