From b127fa17fe4e05b0ee4922c7845978a82dd61590 Mon Sep 17 00:00:00 2001 From: Liam Beckman Date: Fri, 20 Sep 2024 11:15:45 -0700 Subject: [PATCH] Add initial caching to Github Actions workflow --- .github/workflows/build.yml | 51 ++++++++++++++++++++++++++ .github/workflows/compliance-test.yaml | 17 ++++++++- .github/workflows/example.yml | 39 ++++++++++++++++++++ .github/workflows/nextflow.yaml | 24 ++---------- .github/workflows/s3-test.yaml | 2 + .github/workflows/tests.yaml | 2 + 6 files changed, 113 insertions(+), 22 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/example.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..033ba76b --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,51 @@ +name: Funnel Build and Cache + +on: + push: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Set up Go 1.x + uses: actions/setup-go@v5 + with: + go-version: 1.21 + + - name: Check out code + uses: actions/checkout@v2 + + - name: Cache Go modules + uses: actions/cache@v3 + with: + path: | + ~/go/pkg/mod + key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ 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') }} + + - name: Build Funnel (only if cache doesn't exist) + run: | + if [ ! -f ./funnel ]; then + make build + fi + + - name: Cache Funnel binary (after build) + uses: actions/cache@v3 + with: + path: funnel/ + key: ${{ runner.os }}-funnel-bin-${{ hashFiles('**/go.sum') }} + + - name: Upload Funnel binary as artifact (optional) + uses: actions/upload-artifact@v4 + with: + name: funnelBin + path: funnel/ diff --git a/.github/workflows/compliance-test.yaml b/.github/workflows/compliance-test.yaml index 95ed4ecb..950e1e13 100644 --- a/.github/workflows/compliance-test.yaml +++ b/.github/workflows/compliance-test.yaml @@ -25,6 +25,8 @@ name: Compliance Test on: push: + branches: + - main jobs: build: @@ -53,7 +55,8 @@ jobs: matrix: version: [1.0.0, 1.1.0] db: ["boltdb", "mongodb"] - compute: ["local"] + compute: ["local", "kubernetes"] + storage: ["local", "s3"] needs: build runs-on: ubuntu-latest steps: @@ -69,10 +72,22 @@ jobs: - name: Start Funnel server run: | touch config.yml + if [ ${{ matrix.db }} = "mongodb" ]; then make start-mongodb cat `pwd`/tests/mongo.config.yml >> config.yml fi + + if [ ${{ matrix.storage }} = "s3" ]; then + docker run -d -p 9000:9000 --name minio \ + -e "MINIO_ROOT_USER=minioadmin" \ + -e "MINIO_ROOT_PASSWORD=minioadmin" \ + -v /tmp/data:/data \ + -v /tmp/config:/root/.minio \ + minio/minio server /data + cat `pwd`/tests/s3.config.yml >> config.yml + fi + chmod +x funnel ./funnel server run --config `pwd`/config.yml &> funnel.logs & diff --git a/.github/workflows/example.yml b/.github/workflows/example.yml new file mode 100644 index 00000000..5546ab61 --- /dev/null +++ b/.github/workflows/example.yml @@ -0,0 +1,39 @@ +name: Funnel Use Workflow + +on: + workflow_run: + workflows: ["Funnel Build and Cache"] # Name of the build workflow + types: + - completed + +jobs: + use-funnel: + runs-on: ubuntu-latest + + steps: + - name: Set up Go 1.x + uses: actions/setup-go@v5 + with: + go-version: 1.21 + + - name: Check out code + uses: actions/checkout@v2 + + - name: Cache Funnel binary + uses: actions/cache@v3 + with: + path: funnel/ + key: ${{ runner.os }}-funnel-bin-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-funnel-bin- + + - name: Use Funnel binary + run: | + if [ -f ./funnel/funnel ]; then + echo "Using cached Funnel binary" + chmod +x ./funnel/funnel + ./funnel/funnel server --LocalStorage.AllowedDirs $HOME run & + else + echo "Funnel binary not found. Exiting." + exit 1 + fi diff --git a/.github/workflows/nextflow.yaml b/.github/workflows/nextflow.yaml index 33c2c461..29497265 100644 --- a/.github/workflows/nextflow.yaml +++ b/.github/workflows/nextflow.yaml @@ -2,31 +2,13 @@ name: Nextflow Test on: push: + branches: + - main + jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Set up Go 1.x - uses: actions/setup-go@v5 - with: - go-version: 1.21 - - - name: Check out code - uses: actions/checkout@v2 - - - name: Build Funnel (if cache does not exist) - run: make build - - - name: Store Funnel - uses: actions/upload-artifact@v4 - with: - name: funnelBin - path: funnel - nextflow: runs-on: ubuntu-latest - needs: build steps: - name: Download Funnel uses: actions/download-artifact@v2 diff --git a/.github/workflows/s3-test.yaml b/.github/workflows/s3-test.yaml index 1ac1cc24..b2d3ec2b 100644 --- a/.github/workflows/s3-test.yaml +++ b/.github/workflows/s3-test.yaml @@ -5,6 +5,8 @@ name: S3 Integration Test on: push: + branches: + - main jobs: build: diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index dedb8e7a..958fc226 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -2,6 +2,8 @@ name: Go Tests on: push: + branches: + - main jobs: # Temporarily disabling linting