From eac93b6b5ccccf6944d7407d1f62a22c07d2d922 Mon Sep 17 00:00:00 2001 From: Pat Gavlin Date: Thu, 11 Apr 2024 12:44:00 -0700 Subject: [PATCH] Use caching in GHA (#4) This revealed an issue with the `venv` target due to a missing `generates` argument. --- .github/workflows/go.yml | 16 +++++++++++++++- cache.go | 2 ++ docs/BUILD.dawn | 2 +- init.go | 1 + 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index fb19c03..e3d6797 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -1,4 +1,8 @@ -on: [push, pull_request] +on: + push: + branches: + - main + pull_request: name: Test jobs: test: @@ -22,8 +26,18 @@ jobs: uses: actions/checkout@v4 - name: Bootstrap run: go install ./cmd/dawn + - name: Restore cache + uses: actions/cache/restore@v3 + with: + path: .dawn/build + key: dawn-build-${{ github.ref }} - name: Build run: dawn + - name: Save cache + uses: actions/cache/save@v3 + with: + path: .dawn/build + key: dawn-build-${{ github.ref }} - name: Test run: go test ./... -coverprofile=coverage.out - name: Upload coverage data diff --git a/cache.go b/cache.go index 23e6f90..d1e82bb 100644 --- a/cache.go +++ b/cache.go @@ -34,6 +34,8 @@ func (c *cache) get(key string) (starlark.Value, bool) { // once calls the given callable if and only if key is not present in the cache. // // The result is stored in the cache under the given key. +// +// Returns the result of the call or the cached value. // """ // //starlark:builtin diff --git a/docs/BUILD.dawn b/docs/BUILD.dawn index dae5c0d..d3a5af4 100644 --- a/docs/BUILD.dawn +++ b/docs/BUILD.dawn @@ -6,7 +6,7 @@ def run_in_windows_venv(cmd): run_in_venv = run_in_windows_venv if host.os == "windows" else run_in_posix_venv -@target(sources=["requirements.txt"]) +@target(sources=["requirements.txt"], generates=["venv"]) def venv(): """ Creates a venv for the docs build. diff --git a/init.go b/init.go index 7f64ebb..f669e7b 100644 --- a/init.go +++ b/init.go @@ -3,6 +3,7 @@ package dawn import "go.starlark.net/resolve" func init() { + // Relax some Starlark restrictions. resolve.AllowRecursion = true resolve.AllowGlobalReassign = true resolve.AllowSet = true