Skip to content

changing src file in projectB #14

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

Open
wants to merge 52 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
4a07540
test
dana-yaish Oct 12, 2022
dc51ae2
test
dana-yaish Oct 12, 2022
260728c
Merge pull request #3 from dana-yaish/test
dana-yaish Oct 13, 2022
0eae751
remove test
dana-yaish Oct 13, 2022
847c967
Merge pull request #4 from dana-yaish/test1
dana-yaish Oct 13, 2022
caa5c49
add test
dana-yaish Oct 13, 2022
8453812
adding new func
dana-yaish Oct 13, 2022
a4b466f
Merge pull request #5 from dana-yaish/test2
dana-yaish Oct 13, 2022
0a14e26
add new func
dana-yaish Oct 13, 2022
e833825
Merge pull request #6 from dana-yaish/test3
dana-yaish Oct 13, 2022
94d47ca
delete test
dana-yaish Oct 13, 2022
75d78e1
remove second test
dana-yaish Oct 13, 2022
c3c029a
Merge pull request #7 from dana-yaish/test4
dana-yaish Oct 13, 2022
dd47ff9
adding test
dana-yaish Oct 17, 2022
fea5910
force pushing
dana-yaish Oct 17, 2022
eeba010
Merge pull request #9 from dana-yaish/test6
dana-yaish Oct 17, 2022
9153e73
removing tests
dana-yaish May 16, 2023
aa56693
test bazel
dana-yaish Jul 20, 2023
e2b46c3
logging output
dana-yaish Jul 20, 2023
e1c4289
fix
dana-yaish Jul 20, 2023
7685963
fix
dana-yaish Jul 20, 2023
53ce3a3
fix
dana-yaish Jul 20, 2023
0ab88cb
fix
dana-yaish Jul 20, 2023
f660644
fix
dana-yaish Jul 20, 2023
b118cdc
fix
dana-yaish Jul 20, 2023
639e783
fix
dana-yaish Jul 20, 2023
4418707
fix
dana-yaish Jul 20, 2023
f012b62
fix
dana-yaish Jul 20, 2023
f3fee76
fix
dana-yaish Jul 20, 2023
f153a69
fix
dana-yaish Jul 20, 2023
b60befb
test out new fixes
dana-yaish Jul 23, 2023
04aeb41
test out new fixes
dana-yaish Jul 23, 2023
a5c2718
hide token
dana-yaish Jul 24, 2023
aeafa67
hide token
dana-yaish Jul 24, 2023
f6d66c6
hide token
dana-yaish Jul 24, 2023
111adc3
create two projects
dana-yaish Jul 26, 2023
cce1843
fixing paths
dana-yaish Jul 26, 2023
e6c1607
run adder tests
dana-yaish Jul 26, 2023
a94d303
fix adder tests
dana-yaish Jul 26, 2023
3fb7ed0
using remote cache
dana-yaish Jul 26, 2023
f7041fd
do not upload to codecov from the cli
dana-yaish Jul 26, 2023
8fc3f7a
run projectB tests only
dana-yaish Jul 26, 2023
c19d09c
gcp
dana-yaish Jul 27, 2023
f57933a
missing $
dana-yaish Jul 27, 2023
375f3c9
config gcs
dana-yaish Jul 28, 2023
85b77c2
config gcs
dana-yaish Jul 28, 2023
81270f8
config gcs
dana-yaish Jul 28, 2023
69c01ca
config gcs
dana-yaish Jul 28, 2023
8b3cc7c
change cov command
dana-yaish Jul 28, 2023
14c0ed8
add gcp creds
dana-yaish Jul 28, 2023
f3c7704
Merge pull request #13 from dana-yaish/test-bazel
dana-yaish Jul 28, 2023
0006c00
changing src file in projectB
dana-yaish Jul 28, 2023
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
30 changes: 24 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,33 @@ jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: bazelbuild/setup-bazelisk@v2
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: pip install -r requirements.txt
- name: Run tests and collect coverage
run: pytest --cov app
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
- name: give wrapper permission
run: chmod +x app/projectA/codecov_wrapper.sh
- name: run tests by bazel and generate coverage
run: |
python -m pip install --upgrade pip
pip install virtualenv
virtualenv venv
source venv/bin/activate
pip install codecov-cli
echo "$GCP_CREDENTIALS" > service.json
echo "-----"
bazel build //app/...
bazel coverage --run_under //app/projectA:codecov_wrapper.sh \
--test_output=all \
--action_env=GIT_DIR=${PWD}/$(git rev-parse --git-dir) \
--action_env=CODECOV_TOKEN=${{ secrets.CODECOV_TOKEN }} \
--remote_cache=https://storage.googleapis.com/bazel-test-dana \
--google_credentials=service.json \
--combined_report=lcov //app/...
env:
GCP_CREDENTIALS: ${{ secrets.GCP_CREDENTIALS }}
18 changes: 18 additions & 0 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#https://github.com/bazelbuild/rules_python - for using py rules
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "rules_python",
sha256 = "84aec9e21cc56fbc7f1335035a71c850d1b9b5cc6ff497306f84cced9a769841",
strip_prefix = "rules_python-0.23.1",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.23.1/rules_python-0.23.1.tar.gz",
)

load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains")

py_repositories()

python_register_toolchains(
name = "python39",
python_version = "3.9",
register_coverage_tool = True,
)
15 changes: 15 additions & 0 deletions app/projectA/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
py_library(
name="calculator",
srcs=["calculator.py"],

)

py_test(
name="test_calculator",
srcs=["test_calculator.py"],
deps = [
"//app/projectA:calculator",
]
)

exports_files(["codecov_wrapper.sh"])
6 changes: 6 additions & 0 deletions app/calculator.py → app/projectA/calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@ def divide(x, y):
if y == 0:
return 'Cannot divide by 0'
return x * 1.0 / y

def add2(x,y,z):
return x+y+z

def subtract2(x, y,z):
return x - y - z
16 changes: 16 additions & 0 deletions app/projectA/codecov_wrapper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#/bin/bash

# `bazel coverage --run_under foo :bar` basically translates to:
# foo pytest --cov bar/src/a.py bar/src/b.py
# We want to run that `pytest` command unmodified, as below:
"$@"

# codecov doesn't recognise pylcov.dat as a coverage report, renaming it to lcov.dat so codecov can acknowledge it
mv $COVERAGE_DIR/pylcov.dat $COVERAGE_DIR/lcov.dat

# uploading coverage
codecovcli -v create-commit -t $CODECOV_TOKEN
codecovcli -v create-report -t $CODECOV_TOKEN
codecovcli -v do-upload -t $CODECOV_TOKEN -s $COVERAGE_DIR


40 changes: 40 additions & 0 deletions app/projectA/test_calculator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

from app.projectA.calculator import Calculator

import unittest



class TestMethods(unittest.TestCase):
def test_add(self):
self.assertEqual(True, True)

def test_add(self):
self.assertEqual(Calculator.add(1, 2), 3.0)
self.assertEqual(Calculator.add(1.0, 2.0), 3.0)
self.assertEqual(Calculator.add(0, 2.0), 2.0)
self.assertEqual(Calculator.add(2.0, 0), 2.0)
self.assertEqual(Calculator.add(-4, 2.0), -2.0)

def test_subtract(self):
self.assertEqual(Calculator.subtract(1, 2) , -1.0)
self.assertEqual(Calculator.subtract(2, 1) , 1.0)
self.assertEqual(Calculator.subtract(1.0, 2.0) , -1.0)
self.assertEqual(Calculator.subtract(0, 2.0) , -2.0)
self.assertEqual(Calculator.subtract(2.0, 0.0) , 2.0)
self.assertEqual(Calculator.subtract(-4, 2.0) , -6.0)

def test_multiply(self):
self.assertEqual(Calculator.multiply(1, 2) , 2.0)
self.assertEqual(Calculator.multiply(1.0, 2.0) , 2.0)
self.assertEqual(Calculator.multiply(0, 2.0) , 0.0)
self.assertEqual(Calculator.multiply(2.0, 0.0) , 0.0)
self.assertEqual(Calculator.multiply(-4, 2.0) , -8.0)

def test_divide(self):
self.assertEqual(Calculator.divide(1.0, 2.0) , 0.5)
self.assertEqual(Calculator.divide(0, 2.0) , 0)
self.assertEqual(Calculator.divide(-4, 2.0) , -2.0)

if __name__ == "__main__":
unittest.main()
15 changes: 15 additions & 0 deletions app/projectB/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
py_library(
name="adder",
srcs=["adder.py"],

)

py_test(
name="test_adder",
srcs=["test_adder.py"],
deps = [
"//app/projectB:adder",
]
)

exports_files(["codecov_wrapper.sh"])
3 changes: 3 additions & 0 deletions app/projectB/adder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Adder:
def add(self, x, y):
return x + y
16 changes: 16 additions & 0 deletions app/projectB/codecov_wrapper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#/bin/bash

# `bazel coverage --run_under foo :bar` basically translates to:
# foo pytest --cov bar/src/a.py bar/src/b.py
# We want to run that `pytest` command unmodified, as below:
"$@"

# codecov doesn't recognise pylcov.dat as a coverage report, renaming it to lcov.dat so codecov can acknowledge it
mv $COVERAGE_DIR/pylcov.dat $COVERAGE_DIR/lcov.dat

# uploading coverage
codecovcli -v create-commit -t $CODECOV_TOKEN
codecovcli -v create-report -t $CODECOV_TOKEN
codecovcli -v do-upload -t $CODECOV_TOKEN -s $COVERAGE_DIR


11 changes: 11 additions & 0 deletions app/projectB/test_adder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import unittest

from app.projectB.adder import Adder


class TestAdder(unittest.TestCase):
def test_adder(self):
assert 2 + 3.0 == Adder().add(2, 3)

if __name__ == "__main__":
unittest.main()
31 changes: 0 additions & 31 deletions app/test_calculator.py

This file was deleted.