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

Standardizing CI #119

Merged
merged 6 commits into from
Sep 28, 2023
Merged
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
502 changes: 61 additions & 441 deletions .github/workflows/ci.yml

Large diffs are not rendered by default.

43 changes: 0 additions & 43 deletions .github/workflows/create-self-hosted-release.yml

This file was deleted.

14 changes: 14 additions & 0 deletions .github/workflows/self-hosted-release-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Create Self Hosted Release PR

on:
workflow_dispatch:
inputs:
versionName:
description: 'Name of version (ie 23.9.5)'
required: true

jobs:
create-release-pr:
name: Create PR for Release ${{ github.event.inputs.versionName }}
uses: codecov/gha-workflows/.github/workflows/create-self-hosted-pr.yml@main
secrets: inherit
39 changes: 13 additions & 26 deletions .github/workflows/self-hosted-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,17 @@ on:
types: [closed]

jobs:
push_to_registry:
create-release:
name: Tag Release ${{ github.head_ref }} and Push Docker image to Docker Hub
if: ${{ github.event.pull_request.merged == true && startsWith(github.head_ref, 'release/') }}
runs-on: ubuntu-latest
environment: enterprise
permissions:
contents: 'read'
id-token: 'write'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Initialize mandatory git config
run: |
git config user.name "GitHub Actions"
git config user.email [email protected]
- id: get-release-vars
name: Configure Release Vars
run: |
echo "release_version=$(cat VERSION)" >> "$GITHUB_OUTPUT"
- name: Create GH Release
uses: softprops/[email protected]
with:
token: ${{ secrets.RELEASE_GITHUB_TOKEN }}
name: Release ${{ steps.get-release-vars.outputs.release_version }}
tag_name: self-hosted-${{ steps.get-release-vars.outputs.release_version }}
generate_release_notes: true
body: Autogenerated for ${{ steps.get-release-vars.outputs.release_version }}. Created for ${{ github.event.pull_request.html_url }}
if: ${{ github.event.pull_request.merged == true && startsWith(github.head_ref, 'release/') && github.repository_owner == 'codecov' }}
uses: codecov/gha-workflows/.github/workflows/create-self-hosted-release.yml@main
secrets: inherit

push-image:
needs: [create-release]
if: ${{ github.event.pull_request.merged == true && startsWith(github.head_ref, 'release/') && github.repository_owner == 'codecov' }}
uses: codecov/gha-workflows/.github/workflows/self-hosted.yml@main
secrets: inherit
with:
push_release: true
repo: ${{ vars.CODECOV_IMAGE_V2 || 'codecov/self-hosted-worker' }}
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ sha := $(shell git rev-parse --short=7 HEAD)
full_sha := $(shell git rev-parse HEAD)
release_version = `cat VERSION`
_gcr := ${CODECOV_WORKER_GCR_REPO_BASE}

merge_sha := $(shell git merge-base HEAD^ origin/main)
build_date ?= $(shell git show -s --date=iso8601-strict --pretty=format:%cd $$sha)
name ?= worker
branch = $(shell git branch | grep \* | cut -f2 -d' ')
Expand Down Expand Up @@ -224,7 +224,10 @@ test_env.container_static_analysis:
codecovcli -u ${CODECOV_URL} static-analysis --token=${CODECOV_STATIC_TOKEN}

test_env.container_label_analysis:
codecovcli -u ${CODECOV_URL} label-analysis --base-sha=$(shell git merge-base HEAD^ origin/main) --token=${CODECOV_STATIC_TOKEN}
$(shell codecovcli label-analysis --base-sha=${merge_sha} --token=${CODECOV_STATIC_TOKEN} --dry-run --dry-run-output-path=tests_to_run > /dev/null)
sed -i 's/--cov-context=test//g' tests_to_run
sed -i 's/\s\+/\n/g' tests_to_run
python -m pytest --cov=./ --cov-context=test `cat tests_to_run`
Comment on lines +227 to +230
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this munging added for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is doing a bit of hackery to use the dry run output for ATS. This will go away with some changes Gio is working on this sprint.


test_env.container_ats:
codecovcli --codecov-yml-path=codecov_cli.yml do-upload --plugin pycoverage --plugin compress-pycoverage --flag onlysomelabels --fail-on-error
Expand Down
4 changes: 3 additions & 1 deletion services/path_fixer/tests/unit/test_fixpaths.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

# Hand-written TOCs.
paths = [
("a\\ b", ["a b"]),
("./a\\b", ["a/b"]),
("./a\n./b", ["a", "b"]),
("path/target/delombok/a\n./b", ["b"]),
Expand All @@ -30,6 +29,9 @@ class TestFixpaths(BaseTestCase):
def test_clean_toc(self, toc, result):
assert fixpaths.clean_toc(toc) == result

def test_clean_toc_with_space(self):
assert fixpaths.clean_toc("a\\ b") == ["a b"]

@pytest.mark.parametrize("path, result", list(unquoted_files.items()))
def test_unquote_git_path(self, path, result):
assert fixpaths.unquote_git_path(path) == result
Expand Down
2 changes: 1 addition & 1 deletion services/report/languages/tests/unit/test_bullseye.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def fixes(path):
@pytest.mark.parametrize(
"date",
[
(time.strftime("%Y-%m-%d_%H:%M:%S", (time.gmtime(time.time() - 172800)))),
(time.strftime("%Y-%m-%d_%H:00:00", (time.gmtime(time.time() - 172800)))),
"2020-10-28_17:55:47",
],
)
Expand Down
11 changes: 10 additions & 1 deletion services/report/languages/tests/unit/test_clover.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import datetime
import xml.etree.cElementTree as etree
from time import time

Expand Down Expand Up @@ -161,7 +162,15 @@ def fixes(path):

assert processed_report == expected_result

@pytest.mark.parametrize("date", [(int(time()) - 172800), "01-01-2014"])
@pytest.mark.parametrize(
"date",
[
(datetime.datetime.now() - datetime.timedelta(seconds=172800))
.replace(minute=0, second=0)
.strftime("%s"),
"01-01-2014",
],
)
def test_expired(self, date):
with pytest.raises(ReportExpiredException, match="Clover report expired"):
report_builder = ReportBuilder(
Expand Down
11 changes: 10 additions & 1 deletion services/report/languages/tests/unit/test_cobertura.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import datetime
import os
import xml.etree.cElementTree as etree
from time import time
Expand Down Expand Up @@ -194,7 +195,15 @@ def test_timestamp_zero_passes(self):
assert len(processed_report["archive"]["file"]) == 3
assert processed_report["totals"]["c"] == "45.45455"

@pytest.mark.parametrize("date", [(int(time()) - 172800), "01-01-2014"])
@pytest.mark.parametrize(
"date",
[
(datetime.datetime.now() - datetime.timedelta(seconds=172800))
.replace(minute=0, second=0)
.strftime("%s"),
"01-01-2014",
],
)
def test_expired(self, date):
with pytest.raises(ReportExpiredException, match="Cobertura report expired"):
report_builder = ReportBuilder(
Expand Down
11 changes: 10 additions & 1 deletion services/report/languages/tests/unit/test_jacoco.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import datetime
import xml.etree.cElementTree as etree
from time import time

Expand Down Expand Up @@ -151,7 +152,15 @@ def fixes(path):
processed_report = self.convert_report_to_better_readable(report)
assert [path] == list(processed_report["archive"].keys())

@pytest.mark.parametrize("date", [(int(time()) - 172800), "01-01-2014"])
@pytest.mark.parametrize(
"date",
[
(datetime.datetime.now() - datetime.timedelta(seconds=172800))
.replace(minute=0, second=0)
.strftime("%s"),
"01-01-2014",
],
)
def test_expired(self, date):
report_builder = ReportBuilder(
current_yaml={}, sessionid=0, ignored_lines={}, path_fixer=None
Expand Down