From afb48b9fe69ef72f579a0b1474c05f41fa951aba Mon Sep 17 00:00:00 2001 From: Marina Koushnir Date: Wed, 4 Jun 2025 12:46:29 +0300 Subject: [PATCH 1/3] feat(ws): persist coverage report for backend directory #379 Signed-off-by: Marina Koushnir --- .github/workflows/go-coverage.yml | 48 +++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .github/workflows/go-coverage.yml diff --git a/.github/workflows/go-coverage.yml b/.github/workflows/go-coverage.yml new file mode 100644 index 000000000..953fb9d98 --- /dev/null +++ b/.github/workflows/go-coverage.yml @@ -0,0 +1,48 @@ +name: Go Baseline Coverage + +on: + pull_request: + paths: + - 'workspaces/backend/**' + push: + paths: + - 'workspaces/backend/**' + branches: + - notebook-v2 + +jobs: + test: + name: Run Tests and Generate Coverage + runs-on: ubuntu-latest + + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: workspaces/backend/go.mod + check-latest: true + cache-dependency-path: workspaces/backend/go.sum + + - name: Download Dependencies + run: go mod download + + - name: Run Tests with Coverage + working-directory: ./workspaces/backend + run: | + go test ./api/... -coverprofile=coverage.baseline + go tool cover -html=coverage.baseline -o coverage.html + + - name: Configure Git + run: | + git config --global user.name 'GitHub Actions' + git config --global user.email 'github-actions@github.com' + + - name: Commit backend coverage file + working-directory: ./workspaces/backend + run: | + git add coverage.baseline coverage.html + git commit -m "Update coverage baseline" || echo "No changes to commit" + git push From 8bfe21e8a1dec4843bbc065fc37d29e36397b9ff Mon Sep 17 00:00:00 2001 From: CI Bot Date: Thu, 12 Jun 2025 14:58:18 +0300 Subject: [PATCH 2/3] feat(ws): persist coverage report for backend directory #379 Signed-off-by: Marina Koushnir --- .github/workflows/go-coverage.yml | 19 +++++++++++++------ workspaces/backend/api/workspaces_handler.go | 1 + 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/workflows/go-coverage.yml b/.github/workflows/go-coverage.yml index 953fb9d98..d16261089 100644 --- a/.github/workflows/go-coverage.yml +++ b/.github/workflows/go-coverage.yml @@ -10,11 +10,18 @@ on: branches: - notebook-v2 +permissions: + contents: write + jobs: test: name: Run Tests and Generate Coverage runs-on: ubuntu-latest + defaults: + run: + working-directory: workspaces/backend # 👈 where your go.mod is + steps: - name: Checkout Code uses: actions/checkout@v3 @@ -30,19 +37,19 @@ jobs: run: go mod download - name: Run Tests with Coverage - working-directory: ./workspaces/backend run: | go test ./api/... -coverprofile=coverage.baseline go tool cover -html=coverage.baseline -o coverage.html - - name: Configure Git + - name: Set remote to fork + if: github.event_name == 'pull_request' run: | - git config --global user.name 'GitHub Actions' - git config --global user.email 'github-actions@github.com' + git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.event.pull_request.head.repo.full_name }} - name: Commit backend coverage file - working-directory: ./workspaces/backend run: | + git config --global user.name 'GitHub Actions' + git config --global user.email 'github-actions@github.com' git add coverage.baseline coverage.html git commit -m "Update coverage baseline" || echo "No changes to commit" - git push + git push origin HEAD:${{ github.head_ref }} diff --git a/workspaces/backend/api/workspaces_handler.go b/workspaces/backend/api/workspaces_handler.go index a64c04c70..10e93ce75 100644 --- a/workspaces/backend/api/workspaces_handler.go +++ b/workspaces/backend/api/workspaces_handler.go @@ -81,6 +81,7 @@ func (a *App) GetWorkspaceHandler(w http.ResponseWriter, r *http.Request, ps htt }, ), } + if success := a.requireAuth(w, r, authPolicies); !success { return } From c07a51a578ef936d30b33bb5e7a539e8c8cae08d Mon Sep 17 00:00:00 2001 From: CI Bot Date: Thu, 12 Jun 2025 15:07:46 +0300 Subject: [PATCH 3/3] feat(ws): persist coverage report for backend directory #379 Signed-off-by: Marina Koushnir --- .github/workflows/go-coverage.yml | 13 ++----------- workspaces/backend/.gitignore | 2 +- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/.github/workflows/go-coverage.yml b/.github/workflows/go-coverage.yml index d16261089..03a3e81ff 100644 --- a/.github/workflows/go-coverage.yml +++ b/.github/workflows/go-coverage.yml @@ -1,9 +1,6 @@ name: Go Baseline Coverage on: - pull_request: - paths: - - 'workspaces/backend/**' push: paths: - 'workspaces/backend/**' @@ -39,17 +36,11 @@ jobs: - name: Run Tests with Coverage run: | go test ./api/... -coverprofile=coverage.baseline - go tool cover -html=coverage.baseline -o coverage.html - - - name: Set remote to fork - if: github.event_name == 'pull_request' - run: | - git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.event.pull_request.head.repo.full_name }} - name: Commit backend coverage file run: | git config --global user.name 'GitHub Actions' git config --global user.email 'github-actions@github.com' - git add coverage.baseline coverage.html + git add coverage.baseline git commit -m "Update coverage baseline" || echo "No changes to commit" - git push origin HEAD:${{ github.head_ref }} + git push origin HEAD:notebook-v2 diff --git a/workspaces/backend/.gitignore b/workspaces/backend/.gitignore index ce6feea73..e93bdceb1 100644 --- a/workspaces/backend/.gitignore +++ b/workspaces/backend/.gitignore @@ -4,7 +4,7 @@ *.dll *.so *.dylib -bin/* +bin/**/* Dockerfile.cross # Test binary, built with `go test -c`