Skip to content

Commit

Permalink
Only build python 3.12
Browse files Browse the repository at this point in the history
+ disable ATS (not using)
+ disable mutmut (doesn't work with python 3.12)
+ fix test assertion
  • Loading branch information
giovanni-guidini committed May 15, 2024
1 parent 6f5b2ba commit 5739fce
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 119 deletions.
103 changes: 0 additions & 103 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,87 +21,6 @@ jobs:
uses: codecov/gha-workflows/.github/workflows/codecov-startup.yml@v1.2.19
secrets: inherit

ats:
name: ATS
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install docker compose
run: |
sudo curl -SL https://github.com/docker/compose/releases/download/v2.20.0/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
- name: Build
run: |
make test_env.build
- name: Bring containers up
run: |
make test_env.up
# Need the action to support venv
# - name: Run ATS
# uses: codecov/codecov-ats@v0
# env:
# CODECOV_STATIC_TOKEN: ${{ secrets.STATIC_TOKEN }}
# CODECOV_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }}
- name: Run Static Analysis
run: |
docker-compose exec shared codecovcli create-commit --token=${{ secrets.CODECOV_ORG_TOKEN }}
docker-compose exec shared codecovcli static-analysis --token=${{ secrets.STATIC_TOKEN }}
- name: Run Label Analysis
run: |
docker-compose exec shared codecovcli label-analysis --base-sha=$(git merge-base HEAD^ origin/main) --token=${{ secrets.STATIC_TOKEN }}
# Leaving the below for now. We have some super sus test names that defeat shell escaping. If we figure out a path forward we can change to the output mode and get these stats more effectively
# - name: Run Tests
# id: tests
# run: |
# . venv/bin/activate
# START=$(date +%s)
# TESTS_TO_RUN=$(jq -r '.ats_tests_to_run | map(@sh) | join(" ")' analysis.json --raw-output)
# TEST_COUNT=$(jq -r '.ats_tests_to_run | length' analysis.json)
# RUNNER_OPTIONS=$(jq -r '.runner_options | join(" ")' analysis.json | tr -d '\n')
# python -m pytest $(echo $RUNNER_OPTIONS) --cov=./ $(echo $TESTS_TO_RUN)
# END=$(date +%s)
# DURATION=$((END - START))
# echo duration=$DURATION>> "$GITHUB_OUTPUT"
# echo test_count=$TEST_COUNT>> "$GITHUB_OUTPUT"

- name: Upload Coverage
run: |
docker-compose exec shared codecovcli upload-process --flag smart-labels --token ${{ secrets.CODECOV_ORG_TOKEN }} --fail-on-error
# - name: Run Skip Tests
# id: skip
# run: |
# . venv/bin/activate
# START=$(date +%s)
# TESTS_TO_RUN=$(jq -r '.ats_tests_to_skip | map(@sh) | join(" ")' analysis.json --raw-output)
# TEST_COUNT=$(jq -r '.ats_tests_to_skip | length' analysis.json)
# RUNNER_OPTIONS=$(jq -r '.runner_options | join(" ")' analysis.json | tr -d '\n')
# python -m pytest $(echo $RUNNER_OPTIONS) --cov=./ $(echo $TESTS_TO_RUN)
# END=$(date +%s)
# DURATION=$((END - START))
# echo duration=$DURATION>> "$GITHUB_OUTPUT"
# echo test_count=$TEST_COUNT>> "$GITHUB_OUTPUT"
#
#
# - name: Summary
# run: |
# echo "### ATS Summary" >> $GITHUB_STEP_SUMMARY
# echo "" >> $GITHUB_STEP_SUMMARY
# echo "- ${{ steps.tests.outputs.test_count }} tests ran in ${{ steps.tests.outputs.duration }} seconds" >> $GITHUB_STEP_SUMMARY
# echo "- ${{ steps.skip.outputs.test_count }} tests skipped" >> $GITHUB_STEP_SUMMARY
# echo "- Skipped tests took ${{ steps.skip.outputs.duration }} seconds" >> $GITHUB_STEP_SUMMARY
# - name: Upload coverage to Codecov
# uses: codecov/codecov-action@v4-beta
# env:
# CODECOV_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }}
# with:
# flags: smart-labels
# plugins: pycoverage,compress-pycoverage

test:
name: Test
runs-on: ubuntu-latest
Expand Down Expand Up @@ -146,25 +65,3 @@ jobs:
run: |
docker-compose exec shared codecovcli -u ${{ secrets.CODECOV_PUBLIC_QA_URL }} upload-process --flag shared-docker-uploader --token ${{ secrets.CODECOV_PUBLIC_QA_TOKEN }} --fail-on-error
docker-compose exec shared codecovcli -u ${{ secrets.CODECOV_PUBLIC_QA_URL }} do-upload --report-type "test_results" --flag shared-docker-uploader --token ${{ secrets.CODECOV_PUBLIC_QA_TOKEN }} || true
mutation:
name: Run Mutations
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Install docker compose
run: |
sudo curl -SL https://github.com/docker/compose/releases/download/v2.20.0/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
- name: Build
run: |
make test_env.build
- name: Bring containers up
run: |
make test_env.up
- name: Run mutations
run: |
make test_env.mutation
8 changes: 0 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,6 @@ requirements.install:
test_env.install_cli:
pip install codecov-cli

test_env.mutation:
docker-compose exec shared sh -c 'git fetch --no-tags --prune --depth=1 origin main:refs/remotes/origin/main'
docker-compose exec shared sh -c 'git diff origin/main ${full_sha} > data.patch'
docker-compose exec shared sh -c 'pip install mutmut[patch]'
docker-compose exec shared sh -c 'mutmut run --use-patch-file data.patch || true'
docker-compose exec shared sh -c 'mkdir /tmp/artifacts;'
docker-compose exec shared sh -c 'mutmut junitxml > /tmp/artifacts/mut.xml'

test_env.build:
docker-compose build

Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# syntax=docker/dockerfile:1.4
ARG PYTHON_IMAGE=python:3.10-slim-bullseye
ARG PYTHON_IMAGE=python:3.12.2-slim-bullseye

FROM $PYTHON_IMAGE as build

Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
url="https://github.com/codecov/shared",
author="Codecov",
author_email="support@codecov.io",
python_requires=">=3.11",
install_requires=[
"boto3>=1.9.218",
"cerberus",
Expand Down
2 changes: 1 addition & 1 deletion shared/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class MissingConfigException(Exception):
"iam_endpoint": None,
"hash_key": "ab164bf3f7d947f2a0681b215404873e",
},
"database_url": "postgres://postgres:@postgres:5432/postgres",
"database_url": "postgresql://postgres:@postgres:5432/postgres",
},
"site": LEGACY_DEFAULT_SITE_CONFIG,
"setup": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def test_gitlab_service(self, mock_gitlab_url):
mock_gitlab_url.return_value = "gitlab_url"
self.owner.service = "gitlab"
self.assertEqual(self.owner.avatar_url, "gitlab_url")
self.assertTrue(mock_gitlab_url.called_once())
mock_gitlab_url.assert_called_once()

@patch("shared.django_apps.codecov_auth.models.get_config")
def test_gravatar_url(self, mock_get_config):
Expand Down
10 changes: 5 additions & 5 deletions tests/unit/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_get_config_nothing_user_set(self, mocker):
"iam_endpoint": None,
"hash_key": "ab164bf3f7d947f2a0681b215404873e",
},
"database_url": "postgres://postgres:@postgres:5432/postgres",
"database_url": "postgresql://postgres:@postgres:5432/postgres",
}
assert get_config("setup", "segment", "enabled") is False
assert (
Expand Down Expand Up @@ -396,8 +396,8 @@ def test_load_env_var(self, mocker):
"BITBUCKET__CLIENT_SECRET": "BITBUCKET__CLIENT_SECRET",
"SERVICES__GCP__GOOGLE_CREDENTIALS_LOCATION": "/secret/gcs-credentials/path.json",
"GITHUB__INTEGRATION__PEM": "/secrets/github-pem/github.pem",
"SERVICES__DATABASE_URL": "postgres://user:pass@127.0.0.1:5432/postgres",
"SERVICES__TIMESERIES_DATABASE_URL": "postgres://user:pass@timescale:5432/timescale",
"SERVICES__DATABASE_URL": "postgresql://user:pass@127.0.0.1:5432/postgres",
"SERVICES__TIMESERIES_DATABASE_URL": "postgresql://user:pass@timescale:5432/timescale",
"BITBUCKET__BOT__KEY": "BITBUCKET__BOT__KEY",
"SERVICES__MINIO__ACCESS_KEY_ID": "SERVICES__MINIO__ACCESS_KEY_ID",
"SERVICES__MINIO__SECRET_ACCESS_KEY": "SERVICES__MINIO__SECRET_ACCESS_KEY",
Expand Down Expand Up @@ -436,8 +436,8 @@ def test_load_env_var(self, mocker):
"gcp": {
"google_credentials_location": "/secret/gcs-credentials/path.json"
},
"database_url": "postgres://user:pass@127.0.0.1:5432/postgres",
"timeseries_database_url": "postgres://user:pass@timescale:5432/timescale",
"database_url": "postgresql://user:pass@127.0.0.1:5432/postgres",
"timeseries_database_url": "postgresql://user:pass@timescale:5432/timescale",
"redis_url": "SERVICES__REDIS_URL:11234",
},
"setup": {
Expand Down

0 comments on commit 5739fce

Please sign in to comment.