Skip to content

Commit

Permalink
CI: Cache all built go modules (#2081)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmetc committed Feb 28, 2023
1 parent 60b3f63 commit ff17a96
Show file tree
Hide file tree
Showing 7 changed files with 137 additions and 17 deletions.
22 changes: 19 additions & 3 deletions .github/workflows/bats-hub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ env:

jobs:
build:
strategy:
matrix:
go-version: ["1.20.1"]

name: "Build + tests"
runs-on: ubuntu-latest
timeout-minutes: 20
Expand All @@ -23,18 +27,30 @@ jobs:
sudo chmod +w /etc/machine-id
echo githubciXXXXXXXXXXXXXXXXXXXXXXXX | sudo tee /etc/machine-id
- name: "Set up Go 1.20"
- name: "Set up Go ${{ matrix.go-version }}"
uses: actions/setup-go@v3
with:
go-version: 1.20.1
go-version: ${{ matrix.go-version }}
id: go

- name: "Clone CrowdSec"
- name: "Check out CrowdSec repository"
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: true

- name: Cache Go modules
uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
~/.cache/go-build
~/Library/Caches/go-build
%LocalAppData%\go-build
key: ${{ runner.os }}-${{ matrix.go-version }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-${{ matrix.go-version }}-go-
- name: "Install bats dependencies"
env:
GOBIN: /usr/local/bin
Expand Down
20 changes: 18 additions & 2 deletions .github/workflows/bats-mysql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ env:

jobs:
build:
strategy:
matrix:
go-version: ["1.20.1"]

name: "Build + tests"
runs-on: ubuntu-latest
timeout-minutes: 20
Expand All @@ -30,10 +34,10 @@ jobs:
sudo chmod +w /etc/machine-id
echo githubciXXXXXXXXXXXXXXXXXXXXXXXX | sudo tee /etc/machine-id
- name: "Set up Go 1.20"
- name: "Set up Go ${{ matrix.go-version }}"
uses: actions/setup-go@v3
with:
go-version: 1.20.1
go-version: ${{ matrix.go-version }}
id: go

- name: "Check out CrowdSec repository"
Expand All @@ -42,6 +46,18 @@ jobs:
fetch-depth: 0
submodules: true

- name: Cache Go modules
uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
~/.cache/go-build
~/Library/Caches/go-build
%LocalAppData%\go-build
key: ${{ runner.os }}-${{ matrix.go-version }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-${{ matrix.go-version }}-go-
- name: "Install bats dependencies"
env:
GOBIN: /usr/local/bin
Expand Down
20 changes: 18 additions & 2 deletions .github/workflows/bats-postgres.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ env:

jobs:
build:
strategy:
matrix:
go-version: ["1.20.1"]

name: "Build + tests"
runs-on: ubuntu-latest
timeout-minutes: 20
Expand All @@ -31,10 +35,10 @@ jobs:
sudo chmod +w /etc/machine-id
echo githubciXXXXXXXXXXXXXXXXXXXXXXXX | sudo tee /etc/machine-id
- name: "Set up Go 1.20"
- name: "Set up Go ${{ matrix.go-version }}"
uses: actions/setup-go@v3
with:
go-version: 1.20.1
go-version: ${{ matrix.go-version }}
id: go

- name: "Check out CrowdSec repository"
Expand All @@ -43,6 +47,18 @@ jobs:
fetch-depth: 0
submodules: true

- name: Cache Go modules
uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
~/.cache/go-build
~/Library/Caches/go-build
%LocalAppData%\go-build
key: ${{ runner.os }}-${{ matrix.go-version }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-${{ matrix.go-version }}-go-
- name: "Install bats dependencies"
env:
GOBIN: /usr/local/bin
Expand Down
25 changes: 23 additions & 2 deletions .github/workflows/ci-windows-build-msi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,39 @@ on:

jobs:
build:
strategy:
matrix:
go-version: ["1.20.1"]

name: Build
runs-on: windows-2019

steps:
- name: Set up Go 1.20

- name: "Set up Go ${{ matrix.go-version }}"
uses: actions/setup-go@v3
with:
go-version: 1.20.1
go-version: ${{ matrix.go-version }}
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: false

- name: Cache Go modules
uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
~/.cache/go-build
~/Library/Caches/go-build
%LocalAppData%\go-build
key: ${{ runner.os }}-${{ matrix.go-version }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-${{ matrix.go-version }}-go-
- name: Build
run: make windows_installer
- name: Upload MSI
Expand Down
21 changes: 18 additions & 3 deletions .github/workflows/go-tests-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,20 @@ env:
CROWDSEC_FEATURE_DISABLE_HTTP_RETRY_BACKOFF: true

jobs:

build:
strategy:
matrix:
go-version: ["1.20.1"]

name: "Build + tests"
runs-on: windows-2022

steps:

- name: "Set up Go 1.20"
- name: "Set up Go ${{ matrix.go-version }}"
uses: actions/setup-go@v3
with:
go-version: 1.20.1
go-version: ${{ matrix.go-version }}
id: go

- name: Check out CrowdSec repository
Expand All @@ -38,6 +41,18 @@ jobs:
fetch-depth: 0
submodules: false

- name: Cache Go modules
uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
~/.cache/go-build
~/Library/Caches/go-build
%LocalAppData%\go-build
key: ${{ runner.os }}-${{ matrix.go-version }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-${{ matrix.go-version }}-go-
- name: Build
run: |
make build
Expand Down
44 changes: 40 additions & 4 deletions .github/workflows/release_publish-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,36 @@ on:

jobs:
build:
strategy:
matrix:
go-version: ["1.20.1"]

name: Build and upload binary package
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.20
- name: "Set up Go ${{ matrix.go-version }}"
uses: actions/setup-go@v3
with:
go-version: 1.20.1
go-version: ${{ matrix.go-version }}
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: false

- name: Cache Go modules
uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
~/.cache/go-build
~/Library/Caches/go-build
%LocalAppData%\go-build
key: ${{ runner.os }}-${{ matrix.go-version }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-${{ matrix.go-version }}-go-
- name: Build the binaries
run: make release
- name: Upload to release
Expand All @@ -28,19 +46,37 @@ jobs:
args: crowdsec-release.tgz application/x-gzip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

build_static:
strategy:
matrix:
go-version: ["1.20.1"]
name: Build and upload binary package
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.20
- name: "Set up Go ${{ matrix.go-version }}"
uses: actions/setup-go@v3
with:
go-version: 1.20.1
go-version: ${{ matrix.go-version }}
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: false

- name: Cache Go modules
uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
~/.cache/go-build
~/Library/Caches/go-build
%LocalAppData%\go-build
key: ${{ runner.os }}-${{ matrix.go-version }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-${{ matrix.go-version }}-go-
- name: Build the binaries
run: |
make release BUILD_STATIC=yes
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020-2022 Crowdsec
Copyright (c) 2020-2023 Crowdsec

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down

0 comments on commit ff17a96

Please sign in to comment.