Daniel/postgres docker setup #314
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Shared CI | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
jobs: | |
lint: | |
name: Run Lint | |
uses: codecov/gha-workflows/.github/workflows/[email protected] | |
build: | |
name: Build Shared | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- uses: actions/setup-python@v4 | |
id: setup-python | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Cache Requirements | |
id: cache-requirements | |
uses: actions/cache@v3 | |
env: | |
cache-name: cache-requirements | |
with: | |
path: | | |
venv | |
key: ${{ runner.os }}-${{ env.cache-name }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/requirements.txt') }}-${{ hashFiles('**/tests/requirements.txt') }} | |
restore-keys: | | |
${{ runner.os }}-${{ env.cache-name }}-${{ steps.setup-python.outputs.python-version }} | |
- name: Install Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
- name: Install requirements | |
if: ${{ steps.cache-requirements.outputs.cache-hit != 'true' }} | |
run: | | |
python -m venv venv | |
. venv/bin/activate | |
pip install setuptools_rust | |
pip install -r tests/requirements.txt | |
pip install -r requirements.txt | |
python setup.py develop | |
pip install codecov-cli | |
codecovstartup: | |
name: Codecov Startup | |
needs: build | |
uses: codecov/gha-workflows/.github/workflows/[email protected] | |
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 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- 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 tests | |
run: | | |
make test_env.test | |
# Don't upload on forks for now. | |
- name: upload using codecovcli | |
if: ${{ !cancelled() && !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }} | |
run: | | |
docker-compose exec shared codecovcli upload-process --flag shared-docker-uploader --token ${{ secrets.CODECOV_ORG_TOKEN }} --fail-on-error | |
docker-compose exec shared codecovcli do-upload --report-type "test_results" --flag shared-docker-uploader --token ${{ secrets.CODECOV_ORG_TOKEN }} --fail-on-error | |
- name: upload using codecovcli staging | |
if: ${{ !cancelled() && !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }} | |
run: | | |
docker-compose exec shared codecovcli -u ${{ secrets.CODECOV_STAGING_URL }} upload-process --flag shared-docker-uploader --token ${{ secrets.CODECOV_ORG_TOKEN_STAGING }} --fail-on-error | |
docker-compose exec shared codecovcli -u ${{ secrets.CODECOV_STAGING_URL }} do-upload --report-type "test_results" --flag shared-docker-uploader --token ${{ secrets.CODECOV_ORG_TOKEN_STAGING }} || true | |
- name: upload using codecovcli qa | |
if: ${{ !cancelled() && !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }} | |
run: | | |
docker-compose exec shared codecovcli -u ${{ secrets.CODECOV_QA_URL }} upload-process --flag shared-docker-uploader --token ${{ secrets.CODECOV_QA_TOKEN }} --fail-on-error | |
docker-compose exec shared codecovcli -u ${{ secrets.CODECOV_QA_URL }} do-upload --report-type "test_results" --flag shared-docker-uploader --token ${{ secrets.CODECOV_QA_TOKEN }} --fail-on-error | |
- name: upload using codecovcli public qa | |
if: ${{ !cancelled() && !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }} | |
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 |