From abc83f010a492d5fb5db273e45e7c81546f52629 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Thu, 1 Aug 2024 16:18:11 +0200 Subject: [PATCH 1/2] chore: fix checkout and setup-go ordering to optimize cache usage --- .github/workflows/coverage.yml | 1 + .github/workflows/docs.yml | 4 ++++ .github/workflows/unit-tests.yaml | 18 ++++++++++-------- .github/workflows/wasm.yml | 9 +++++---- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 10ff7a3542..41a561a5d2 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -9,6 +9,7 @@ jobs: build: runs-on: ubuntu-latest steps: + # Checkout should always be before setup-go to ensure caching is working - uses: actions/checkout@v4 with: fetch-depth: 2 diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 246a7d9f2d..75ffa0cdc0 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -7,7 +7,11 @@ jobs: name: Ensure docs are generated runs-on: ubuntu-latest steps: + # Checkout should always be before setup-go to ensure caching is working - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: '1.22' - name: Generate code run: go run ./cmd/scw-doc-gen env: diff --git a/.github/workflows/unit-tests.yaml b/.github/workflows/unit-tests.yaml index ef73dc3ec1..8925baad66 100644 --- a/.github/workflows/unit-tests.yaml +++ b/.github/workflows/unit-tests.yaml @@ -12,6 +12,11 @@ jobs: platform: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.platform }} steps: + # Checkout should always be before setup-go to ensure caching is working + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 1 - name: Install Go uses: actions/setup-go@v5 with: @@ -20,10 +25,6 @@ jobs: run: | git config --global core.autocrlf false git config --global core.eol lf - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 1 - name: Run unit tests run: go test ./... - name: Execute main binary # Test the runtime for potential panics. @@ -36,14 +37,15 @@ jobs: platform: [ubuntu-latest] runs-on: ${{ matrix.platform }} steps: - - name: Install Go - uses: actions/setup-go@v5 - with: - go-version: ${{ matrix.go-version }} + # Checkout should always be before setup-go to ensure caching is working - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 1 + - name: Install Go + uses: actions/setup-go@v5 + with: + go-version: ${{ matrix.go-version }} - name: Build binaries run: ./scripts/build.sh - name: Print binaries size diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index f605a7a520..2e5c7814cf 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -12,6 +12,11 @@ jobs: platform: [ubuntu-latest] runs-on: ${{ matrix.platform }} steps: + # Checkout should always be before setup-go to ensure caching is working + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 1 - name: Install Go uses: actions/setup-go@v5 with: @@ -20,10 +25,6 @@ jobs: uses: pnpm/action-setup@v4 with: version: 6.0.2 - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 1 - name: Build run: ./scripts/build-wasm.sh - name: Run npm package tests From 374d6511bf1843ad415170460c232ea807f91a7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Wed, 7 Aug 2024 13:52:12 +0200 Subject: [PATCH 2/2] Fix --- .github/workflows/unit-tests.yaml | 32 +++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/unit-tests.yaml b/.github/workflows/unit-tests.yaml index 8925baad66..43f7415ae4 100644 --- a/.github/workflows/unit-tests.yaml +++ b/.github/workflows/unit-tests.yaml @@ -12,23 +12,23 @@ jobs: platform: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.platform }} steps: + - name: Set git to use LF to avoid problem with goldens on windows + run: | + git config --global core.autocrlf false + git config --global core.eol lf # Checkout should always be before setup-go to ensure caching is working - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 1 - - name: Install Go - uses: actions/setup-go@v5 - with: - go-version: ${{ matrix.go-version }} - - name: Set git to use LF to avoid problem with goldens on windows - run: | - git config --global core.autocrlf false - git config --global core.eol lf - - name: Run unit tests - run: go test ./... - - name: Execute main binary # Test the runtime for potential panics. - run: go run cmd/scw/main.go -h + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 1 + - name: Install Go + uses: actions/setup-go@v5 + with: + go-version: ${{ matrix.go-version }} + - name: Run unit tests + run: go test ./... + - name: Execute main binary # Test the runtime for potential panics. + run: go run cmd/scw/main.go -h build-tests: strategy: