From 6b36f9058c64aa6890035350b3e18c9f89133cfd Mon Sep 17 00:00:00 2001 From: hangpersonal Date: Mon, 20 Oct 2025 21:24:46 -0700 Subject: [PATCH] Add .gitea/workflows/*.yaml --- .../{cache-verify.yml => cache-verify1.yml} | 100 +++++++++--------- .gitea/workflows/cache-verify2.yml | 26 +++++ 2 files changed, 76 insertions(+), 50 deletions(-) rename .gitea/workflows/{cache-verify.yml => cache-verify1.yml} (96%) create mode 100644 .gitea/workflows/cache-verify2.yml diff --git a/.gitea/workflows/cache-verify.yml b/.gitea/workflows/cache-verify1.yml similarity index 96% rename from .gitea/workflows/cache-verify.yml rename to .gitea/workflows/cache-verify1.yml index 6c3fe96..9405427 100644 --- a/.gitea/workflows/cache-verify.yml +++ b/.gitea/workflows/cache-verify1.yml @@ -1,50 +1,50 @@ -name: Cache Verify - -on: - workflow_dispatch: - -jobs: - cache-verify: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - # 1) Show what cache/runtimes URLs the runner injected into this job - - name: Print cache environment - run: | - echo "ACTIONS_CACHE_URL=${ACTIONS_CACHE_URL}" - echo "ACTIONS_RUNTIME_URL=${ACTIONS_RUNTIME_URL}" - - # 2) Ping the cache status endpoint (works with either host IP or service name) - - name: Probe cache server - run: | - URL="${ACTIONS_CACHE_URL%/}/_apis/artifactcache/status" - echo "Checking: $URL" - if command -v curl >/dev/null 2>&1; then - curl -fsS "$URL" - else - wget -qO- "$URL" - fi - - # 3) Use the cache action with a stable key - # - First run => MISS (will SAVE at the end) - # - Second run => HIT - - name: Use actions/cache - uses: actions/cache@v4 - with: - path: ~/.cache/demo - key: cache-verify-${{ runner.os }}-v1 - - # 4) Write a marker file so we can see reuse across runs - - name: Write marker - run: | - mkdir -p ~/.cache/demo - date -u +"%Y-%m-%dT%H:%M:%SZ" > ~/.cache/demo/when.txt - echo "Wrote: $(cat ~/.cache/demo/when.txt)" - - # 5) Read marker (on a cache HIT, this value will be from the previous run) - - name: Read marker - run: | - echo "Marker content:" - cat ~/.cache/demo/when.txt || echo "" +name: Cache Verify + +on: + workflow_dispatch: + +jobs: + cache-verify: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + # 1) Show what cache/runtimes URLs the runner injected into this job + - name: Print cache environment + run: | + echo "ACTIONS_CACHE_URL=${ACTIONS_CACHE_URL}" + echo "ACTIONS_RUNTIME_URL=${ACTIONS_RUNTIME_URL}" + + # 2) Ping the cache status endpoint (works with either host IP or service name) + - name: Probe cache server + run: | + URL="${ACTIONS_CACHE_URL%/}/_apis/artifactcache/status" + echo "Checking: $URL" + if command -v curl >/dev/null 2>&1; then + curl -fsS "$URL" + else + wget -qO- "$URL" + fi + + # 3) Use the cache action with a stable key + # - First run => MISS (will SAVE at the end) + # - Second run => HIT + - name: Use actions/cache + uses: actions/cache@v4 + with: + path: ~/.cache/demo + key: cache-verify-${{ runner.os }}-v1 + + # 4) Write a marker file so we can see reuse across runs + - name: Write marker + run: | + mkdir -p ~/.cache/demo + date -u +"%Y-%m-%dT%H:%M:%SZ" > ~/.cache/demo/when.txt + echo "Wrote: $(cat ~/.cache/demo/when.txt)" + + # 5) Read marker (on a cache HIT, this value will be from the previous run) + - name: Read marker + run: | + echo "Marker content:" + cat ~/.cache/demo/when.txt || echo "" diff --git a/.gitea/workflows/cache-verify2.yml b/.gitea/workflows/cache-verify2.yml new file mode 100644 index 0000000..0231215 --- /dev/null +++ b/.gitea/workflows/cache-verify2.yml @@ -0,0 +1,26 @@ +name: Caching with Go +on: push +jobs: + Cache-Go: + name: Cache Go + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + with: + go-version: '>=1.20.1' + - uses: https://gitea.com/actions/go-hashfiles@v0.0.1 + id: hash-go + with: + patterns: | + go.mod + go.sum + - name: cache go + id: cache-go + uses: actions/cache@v3 + with: # Specify with your cache path + path: | + /your_cache_path + key: go_path-${{ steps.hash-go.outputs.hash }} + restore-keys: |- + go_cache-${{ steps.hash-go.outputs.hash }} \ No newline at end of file