diff --git a/.github/workflows/coverage.yaml b/.github/workflows/coverage.yaml index 2c1fed77b..d1530ef25 100644 --- a/.github/workflows/coverage.yaml +++ b/.github/workflows/coverage.yaml @@ -1,6 +1,11 @@ name: coverage -on: [push] +on: + push: + pull_request_target: + +permissions: + contents: read jobs: coverage: @@ -15,7 +20,7 @@ jobs: - name: Checkout uses: actions/checkout@v3 with: - ref: ${{ matrix.branch == 'main' && 'main' || '' }} + ref: ${{ matrix.branch == 'main' && 'main' || (github.event.pull_request && format('refs/pull/{0}/merge', github.event.pull_request.number)) || '' }} - name: Bazel cache id: bazel-cache @@ -48,6 +53,9 @@ jobs: comment: runs-on: ubuntu-latest needs: [coverage] + permissions: + pull-requests: write + steps: - uses: actions/github-script@v6 with: @@ -55,10 +63,18 @@ jobs: const pr = ${{fromJson(needs.coverage.outputs.cov-pr).totals.percent_covered}}; const main = ${{fromJson(needs.coverage.outputs.cov-main).totals.percent_covered}}; const diff = pr - main; - github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: `### Coverage report - **Main**: ${main.toFixed(2)}% | **PR**: ${pr.toFixed(2)}% | **Diff: ${diff.toFixed(2)} ${diff >= 0 ? '✅' : '⚠️'}**` - }) + const report = `### Coverage report + **Main**: ${main.toFixed(2)}% | **PR**: ${pr.toFixed(2)}% | **Diff: ${diff.toFixed(2)} ${diff >= 0 ? '✅' : '⚠️'}**`; + if (context.issue.number) { + try { + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: report + }) + } catch (e) { + console.log("This happens when a PR from a fork triggers a workflow", e) + } + } + await core.summary.addRaw(report).write() diff --git a/temporian/test/api_beam_test.py b/temporian/test/api_beam_test.py index 12ef96260..58aeb45ec 100644 --- a/temporian/test/api_beam_test.py +++ b/temporian/test/api_beam_test.py @@ -27,6 +27,7 @@ class TFPTest(absltest.TestCase): def test_run_base(self): tmp_dir = tempfile.mkdtemp() + input_path = os.path.join(tmp_dir, "input.csv") output_path = os.path.join(tmp_dir, "output.csv")