Skip to content

Commit 111adc3

Browse files
committed
create two projects
1 parent f6d66c6 commit 111adc3

File tree

8 files changed

+45
-2
lines changed

8 files changed

+45
-2
lines changed

app/BUILD.bazel renamed to app/projectA/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ py_test(
88
name="test_calculator",
99
srcs=["test_calculator.py"],
1010
deps = [
11-
"//app:calculator",
11+
"//app/projectA:calculator",
1212
]
1313
)
1414

File renamed without changes.
File renamed without changes.

app/test_calculator.py renamed to app/projectA/test_calculator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
from app.calculator import Calculator
2+
from app.projectA.calculator import Calculator
33

44
import unittest
55

app/projectB/BUILD.bazel

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
py_library(
2+
name="adder",
3+
srcs=["adder.py"],
4+
5+
)
6+
7+
py_test(
8+
name="test_adder",
9+
srcs=["test_adder.py"],
10+
deps = [
11+
"//app/projectB:adder",
12+
]
13+
)
14+
15+
exports_files(["codecov_wrapper.sh"])

app/projectB/adder.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class Adder:
2+
def add(self, x, y):
3+
return x + y

app/projectB/codecov_wrapper.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#/bin/bash
2+
3+
# `bazel coverage --run_under foo :bar` basically translates to:
4+
# foo pytest --cov bar/src/a.py bar/src/b.py
5+
# We want to run that `pytest` command unmodified, as below:
6+
"$@"
7+
8+
# codecov doesn't recognise pylcov.dat as a coverage report, renaming it to lcov.dat so codecov can acknowledge it
9+
mv $COVERAGE_DIR/pylcov.dat $COVERAGE_DIR/lcov.dat
10+
11+
# uploading coverage
12+
codecovcli -v create-commit -t $CODECOV_TOKEN
13+
codecovcli -v create-report -t $CODECOV_TOKEN
14+
codecovcli -v do-upload -t $CODECOV_TOKEN -s $COVERAGE_DIR
15+
16+

app/projectB/test_adder.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import unittest
2+
3+
from app.projectB.adder import Adder
4+
5+
6+
7+
class TestAdder(unittest.TestCase):
8+
def test_adder(self, x, y):
9+
assert x + y == Adder.add(x, y)

0 commit comments

Comments
 (0)