diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ad0aace9..4494a88a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,11 +1,12 @@ name: Funnel Build and Cache on: - push: + workflow_call: jobs: build: runs-on: ubuntu-latest + steps: - name: Set up Go 1.x uses: actions/setup-go@v5 @@ -20,15 +21,19 @@ jobs: with: path: | ~/go/pkg/mod - key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} + key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}-${{ github.ref }} restore-keys: | + ${{ runner.os }}-go-mod-${{ github.ref }} ${{ runner.os }}-go-mod- - name: Cache Funnel binary uses: actions/cache@v3 with: - path: ./funnel # Path to the Funnel executable - key: ${{ runner.os }}-funnel-bin-${{ hashFiles('**/go.sum') }} + path: ./funnel + key: ${{ runner.os }}-funnel-bin-${{ hashFiles('**/go.sum') }}-${{ github.ref }} + restore-keys: | + ${{ runner.os }}-funnel-bin-${{ github.ref }} + ${{ runner.os }}-funnel-bin- - name: Build Funnel (only if cache doesn't exist) run: | @@ -40,7 +45,7 @@ jobs: uses: actions/cache@v3 with: path: funnel/ - key: ${{ runner.os }}-funnel-bin-${{ hashFiles('**/go.sum') }} + key: ${{ runner.os }}-funnel-bin-${{ hashFiles('**/go.sum') }}-${{ github.ref }} - name: Upload Funnel binary as artifact (optional) uses: actions/upload-artifact@v4 diff --git a/.github/workflows/example.yml b/.github/workflows/example.yml index 91288333..07f00375 100644 --- a/.github/workflows/example.yml +++ b/.github/workflows/example.yml @@ -1,12 +1,17 @@ name: Funnel Use Workflow on: - workflow_run: - workflows: ["Funnel Build and Cache"] # Name of the build workflow - types: - - completed - + push: + branches: + - '**' # Triggers on all branches + pull_request: + branches: + - '**' + jobs: + build: + uses: ./.github/workflows/build.yml # use the callable tests job to run tests + use-funnel: runs-on: ubuntu-latest @@ -23,17 +28,14 @@ jobs: uses: actions/cache@v3 with: path: funnel/ - key: ${{ runner.os }}-funnel-bin-${{ hashFiles('**/go.sum') }} + key: ${{ runner.os }}-funnel-bin-${{ hashFiles('**/go.sum') }}-${{ github.ref }} restore-keys: | + ${{ runner.os }}-funnel-bin-${{ github.ref }} ${{ runner.os }}-funnel-bin- - name: Use Funnel binary run: | - if [ -f ./funnel ]; then echo "Using cached Funnel binary" chmod +x ./funnel - ./funnel server --LocalStorage.AllowedDirs $HOME run & - else - echo "Funnel binary not found. Exiting." - exit 1 - fi + ./funnel version +