From 073ab4510c780f6ea1085f36ae38b1b9c733852f Mon Sep 17 00:00:00 2001 From: Sam Washko Date: Thu, 28 Sep 2023 16:30:13 -0700 Subject: [PATCH 01/16] Create coverage.yml --- .github/workflows/coverage.yml | 43 ++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/coverage.yml diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 00000000..612469b9 --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,43 @@ +name: Coverage + +on: + push: + branches: main + pull_request: + branches: "*" + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.8", "3.9", "3.10"] + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - uses: snok/install-poetry@v1 + with: + virtualenvs-create: true + virtualenvs-in-project: true + installer-parallel: true + - name: Load cached venv + id: cached-poetry-dependencies + uses: actions/cache@v3 + with: + path: .venv + key: venv-test-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} + - name: Install Dependencies + if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' + run: | + make install-test + - name: Run Coverage + run: | + make test + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v3 + with: + token: ${{ secrets.CODECOV_TOKEN }} From 37f84532d9782ff40a14cd69ac3b259b5f5a74dd Mon Sep 17 00:00:00 2001 From: Sam Washko Date: Thu, 28 Sep 2023 16:49:15 -0700 Subject: [PATCH 02/16] comment --- .github/workflows/coverage.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 612469b9..3997c979 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -13,6 +13,9 @@ jobs: matrix: python-version: ["3.8", "3.9", "3.10"] + permissions: + pull-requests: write + steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} @@ -40,4 +43,9 @@ jobs: - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v3 with: - token: ${{ secrets.CODECOV_TOKEN }} + token: ${{ secrets.CODECOV_TOKEN }} + - uses: mshick/add-pr-comment@v2 + with: + message: | + **Hello** + 🌏 From 1784267189fd2ebd24756b6ec775e66720ea20ad Mon Sep 17 00:00:00 2001 From: Sam Washko Date: Thu, 28 Sep 2023 16:55:38 -0700 Subject: [PATCH 03/16] separate job --- .github/workflows/coverage.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 3997c979..20fe7bb4 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -43,7 +43,12 @@ jobs: - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v3 with: - token: ${{ secrets.CODECOV_TOKEN }} + token: ${{ secrets.CODECOV_TOKEN }} + job: + runs-on: ubuntu-latest + permissions: + pull-requests: write + steps: - uses: mshick/add-pr-comment@v2 with: message: | From 2a7bc1ad35176e9e98519c6e8a77d692aa2cad4a Mon Sep 17 00:00:00 2001 From: Sam Washko Date: Thu, 28 Sep 2023 16:56:20 -0700 Subject: [PATCH 04/16] message --- .github/workflows/coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 20fe7bb4..d0612bc2 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -53,4 +53,4 @@ jobs: with: message: | **Hello** - 🌏 + 🌏 - separate job From e1e2452e5ff8781022914aa839a2ccced5221782 Mon Sep 17 00:00:00 2001 From: Sam Washko Date: Thu, 28 Sep 2023 17:01:40 -0700 Subject: [PATCH 05/16] needs job1 output --- .github/workflows/coverage.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index d0612bc2..e8c33de8 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -7,7 +7,7 @@ on: branches: "*" jobs: - test: + job1: runs-on: ubuntu-latest strategy: matrix: @@ -15,8 +15,12 @@ jobs: permissions: pull-requests: write + outputs: + testoutput: S{{ steps.step1.outputs.test }} steps: + - id: step1 + run: echo "test=hello" >> "$GITHUB_OUTPUT" - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 @@ -44,13 +48,15 @@ jobs: uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN }} - job: + job2: runs-on: ubuntu-latest permissions: pull-requests: write + needs: job1 steps: - uses: mshick/add-pr-comment@v2 with: message: | **Hello** 🌏 - separate job + ${{needs.job1.outputs.testoutput}} From 22c3d0bb6dd3d64b93d5fe1a4e3216f439a496fc Mon Sep 17 00:00:00 2001 From: Sam Washko Date: Thu, 28 Sep 2023 17:07:13 -0700 Subject: [PATCH 06/16] run --- .github/workflows/coverage.yml | 1 + tests/test_modelscan.py | 30 +++++++++++++++--------------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index e8c33de8..3f7d7796 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -60,3 +60,4 @@ jobs: **Hello** 🌏 - separate job ${{needs.job1.outputs.testoutput}} + - run: echo ${{needs.job1.outputs.testoutput}} diff --git a/tests/test_modelscan.py b/tests/test_modelscan.py index d6395226..6a37f5d2 100644 --- a/tests/test_modelscan.py +++ b/tests/test_modelscan.py @@ -685,21 +685,21 @@ def test_scan_directory_path(pickle_file_path: str) -> None: compare_results(ms.issues.all_issues, expected) -def test_scan_huggingface_model() -> None: - expected = [ - Issue( - IssueCode.UNSAFE_OPERATOR, - IssueSeverity.CRITICAL, - OperatorIssueDetails( - "__builtin__", - "eval", - "https://huggingface.co/ykilcher/totally-harmless-model/resolve/main/pytorch_model.bin:archive/data.pkl", - ), - ) - ] - ms = Modelscan() - ms.scan_huggingface_model("ykilcher/totally-harmless-model") - assert ms.issues.all_issues == expected +# def test_scan_huggingface_model() -> None: +# expected = [ +# Issue( +# IssueCode.UNSAFE_OPERATOR, +# IssueSeverity.CRITICAL, +# OperatorIssueDetails( +# "__builtin__", +# "eval", +# "https://huggingface.co/ykilcher/totally-harmless-model/resolve/main/pytorch_model.bin:archive/data.pkl", +# ), +# ) +# ] +# ms = Modelscan() +# ms.scan_huggingface_model("ykilcher/totally-harmless-model") +# assert ms.issues.all_issues == expected # def test_scan_tf() -> None: From b8570e873cb25ad47379b9bc0fef60034823c30b Mon Sep 17 00:00:00 2001 From: Sam Washko Date: Thu, 28 Sep 2023 17:13:03 -0700 Subject: [PATCH 07/16] [] --- .github/workflows/coverage.yml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 3f7d7796..b495a073 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -43,21 +43,20 @@ jobs: make install-test - name: Run Coverage run: | - make test - - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v3 - with: - token: ${{ secrets.CODECOV_TOKEN }} + make coverage + job2: runs-on: ubuntu-latest permissions: pull-requests: write needs: job1 steps: - - uses: mshick/add-pr-comment@v2 + - name: Post Comment + uses: mshick/add-pr-comment@v2 with: message: | **Hello** 🌏 - separate job - ${{needs.job1.outputs.testoutput}} - - run: echo ${{needs.job1.outputs.testoutput}} + [${{needs.job1.outputs.testoutput}}] + - name: Echo + run: echo [${{needs.job1.outputs.testoutput}}] From 6f661a017c5bb83af2fc6b406db470f8b7f17ccc Mon Sep 17 00:00:00 2001 From: Sam Washko Date: Thu, 28 Sep 2023 17:20:43 -0700 Subject: [PATCH 08/16] $ typo --- .github/workflows/coverage.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index b495a073..6631ff64 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -11,12 +11,12 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.8", "3.9", "3.10"] + python-version: ["3.8"] permissions: pull-requests: write outputs: - testoutput: S{{ steps.step1.outputs.test }} + testoutput: ${{ steps.step1.outputs.test }} steps: - id: step1 From 8852ba37a88ed9badb1e76d68048079b0ac31416 Mon Sep 17 00:00:00 2001 From: Sam Washko Date: Thu, 28 Sep 2023 17:25:47 -0700 Subject: [PATCH 09/16] comment coverage output --- .github/workflows/coverage.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 6631ff64..e3fe0cb0 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -17,6 +17,7 @@ jobs: pull-requests: write outputs: testoutput: ${{ steps.step1.outputs.test }} + coverage: ${{ steps.coverage.outputs.coverage-report }} steps: - id: step1 @@ -42,8 +43,9 @@ jobs: run: | make install-test - name: Run Coverage + id: coverage run: | - make coverage + echo "coverage-report=$(make coverage)" >> "$GITHUB_OUTPUT" job2: runs-on: ubuntu-latest @@ -58,5 +60,6 @@ jobs: **Hello** 🌏 - separate job [${{needs.job1.outputs.testoutput}}] + [${{needs.job1.outputs.coverage}}] - name: Echo run: echo [${{needs.job1.outputs.testoutput}}] From d3df30e71561a47ad88e84113630c0981a43b2f3 Mon Sep 17 00:00:00 2001 From: Sam Washko Date: Thu, 28 Sep 2023 17:31:58 -0700 Subject: [PATCH 10/16] echo 2 commands --- .github/workflows/coverage.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index e3fe0cb0..ec812a4f 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -45,7 +45,8 @@ jobs: - name: Run Coverage id: coverage run: | - echo "coverage-report=$(make coverage)" >> "$GITHUB_OUTPUT" + report=$(make coverage) + echo "coverage-report=$report" >> "$GITHUB_OUTPUT" job2: runs-on: ubuntu-latest From d207a28a923e951c3aec61043e3c4bed1baddb87 Mon Sep 17 00:00:00 2001 From: Sam Washko Date: Thu, 28 Sep 2023 17:42:14 -0700 Subject: [PATCH 11/16] << --- .github/workflows/coverage.yml | 5 +---- Makefile | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index ec812a4f..83d16f85 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -12,9 +12,6 @@ jobs: strategy: matrix: python-version: ["3.8"] - - permissions: - pull-requests: write outputs: testoutput: ${{ steps.step1.outputs.test }} coverage: ${{ steps.coverage.outputs.coverage-report }} @@ -46,7 +43,7 @@ jobs: id: coverage run: | report=$(make coverage) - echo "coverage-report=$report" >> "$GITHUB_OUTPUT" + echo "coverage-report<<$report" >> "$GITHUB_OUTPUT" job2: runs-on: ubuntu-latest diff --git a/Makefile b/Makefile index 5c382ba2..d8995fda 100644 --- a/Makefile +++ b/Makefile @@ -41,4 +41,4 @@ format: black . coverage: - poetry run pytest -v --cov=./ + poetry run pytest -q --cov=./ From 2c7473344110c773ba690425016a5cdfc1cd5df9 Mon Sep 17 00:00:00 2001 From: Sam Washko Date: Thu, 28 Sep 2023 17:51:01 -0700 Subject: [PATCH 12/16] "" --- .github/workflows/coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 83d16f85..2079eb12 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -42,7 +42,7 @@ jobs: - name: Run Coverage id: coverage run: | - report=$(make coverage) + report="$(make coverage)" echo "coverage-report<<$report" >> "$GITHUB_OUTPUT" job2: From 979d6177b2ff6959c0ac1adf40118b4142b079ab Mon Sep 17 00:00:00 2001 From: Sam Washko Date: Thu, 28 Sep 2023 17:53:55 -0700 Subject: [PATCH 13/16] multiple steps --- .github/workflows/coverage.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 2079eb12..6b33e327 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -40,10 +40,9 @@ jobs: run: | make install-test - name: Run Coverage - id: coverage - run: | - report="$(make coverage)" - echo "coverage-report<<$report" >> "$GITHUB_OUTPUT" + run: report="$(make coverage)" + - id: coverage + run: echo "coverage-report<<$report" >> "$GITHUB_OUTPUT" job2: runs-on: ubuntu-latest From a1ed3957b38f60da80afc10062856af4116423e8 Mon Sep 17 00:00:00 2001 From: Sam Washko Date: Thu, 28 Sep 2023 17:57:59 -0700 Subject: [PATCH 14/16] = --- .github/workflows/coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 6b33e327..80230511 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -42,7 +42,7 @@ jobs: - name: Run Coverage run: report="$(make coverage)" - id: coverage - run: echo "coverage-report<<$report" >> "$GITHUB_OUTPUT" + run: echo "coverage-report=$report" >> "$GITHUB_OUTPUT" job2: runs-on: ubuntu-latest From d2ca57c47a57bee7ef03d0c18cef4e4085e7f49f Mon Sep 17 00:00:00 2001 From: Sam Washko Date: Thu, 28 Sep 2023 18:02:24 -0700 Subject: [PATCH 15/16] 1 step --- .github/workflows/coverage.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 80230511..dded62f0 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -40,9 +40,10 @@ jobs: run: | make install-test - name: Run Coverage - run: report="$(make coverage)" - - id: coverage - run: echo "coverage-report=$report" >> "$GITHUB_OUTPUT" + id: coverage + run: | + report=$(make coverage) + echo "coverage-report=$report" >> "$GITHUB_OUTPUT" job2: runs-on: ubuntu-latest @@ -59,4 +60,4 @@ jobs: [${{needs.job1.outputs.testoutput}}] [${{needs.job1.outputs.coverage}}] - name: Echo - run: echo [${{needs.job1.outputs.testoutput}}] + run: echo [${{needs.job1.outputs.coverage}}] From 3f654839801a17d649e6d356492c5137d00cc9db Mon Sep 17 00:00:00 2001 From: Sam Washko Date: Thu, 28 Sep 2023 18:07:50 -0700 Subject: [PATCH 16/16] delimeter --- .github/workflows/coverage.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index dded62f0..399999ca 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -42,8 +42,11 @@ jobs: - name: Run Coverage id: coverage run: | - report=$(make coverage) - echo "coverage-report=$report" >> "$GITHUB_OUTPUT" + { + echo 'coverage-report<> "$GITHUB_OUTPUT">> "$GITHUB_OUTPUT" job2: runs-on: ubuntu-latest