CI: Cache all built go modules (#2081)

This commit is contained in:
mmetc 2023-02-28 17:25:09 +01:00 committed by GitHub
parent 60b3f63851
commit ff17a961fc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 137 additions and 17 deletions

View file

@ -13,6 +13,10 @@ env:
jobs: jobs:
build: build:
strategy:
matrix:
go-version: ["1.20.1"]
name: "Build + tests" name: "Build + tests"
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 20 timeout-minutes: 20
@ -23,18 +27,30 @@ jobs:
sudo chmod +w /etc/machine-id sudo chmod +w /etc/machine-id
echo githubciXXXXXXXXXXXXXXXXXXXXXXXX | sudo tee /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 uses: actions/setup-go@v3
with: with:
go-version: 1.20.1 go-version: ${{ matrix.go-version }}
id: go id: go
- name: "Clone CrowdSec" - name: "Check out CrowdSec repository"
uses: actions/checkout@v3 uses: actions/checkout@v3
with: with:
fetch-depth: 0 fetch-depth: 0
submodules: true 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" - name: "Install bats dependencies"
env: env:
GOBIN: /usr/local/bin GOBIN: /usr/local/bin

View file

@ -12,6 +12,10 @@ env:
jobs: jobs:
build: build:
strategy:
matrix:
go-version: ["1.20.1"]
name: "Build + tests" name: "Build + tests"
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 20 timeout-minutes: 20
@ -30,10 +34,10 @@ jobs:
sudo chmod +w /etc/machine-id sudo chmod +w /etc/machine-id
echo githubciXXXXXXXXXXXXXXXXXXXXXXXX | sudo tee /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 uses: actions/setup-go@v3
with: with:
go-version: 1.20.1 go-version: ${{ matrix.go-version }}
id: go id: go
- name: "Check out CrowdSec repository" - name: "Check out CrowdSec repository"
@ -42,6 +46,18 @@ jobs:
fetch-depth: 0 fetch-depth: 0
submodules: true 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" - name: "Install bats dependencies"
env: env:
GOBIN: /usr/local/bin GOBIN: /usr/local/bin

View file

@ -8,6 +8,10 @@ env:
jobs: jobs:
build: build:
strategy:
matrix:
go-version: ["1.20.1"]
name: "Build + tests" name: "Build + tests"
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 20 timeout-minutes: 20
@ -31,10 +35,10 @@ jobs:
sudo chmod +w /etc/machine-id sudo chmod +w /etc/machine-id
echo githubciXXXXXXXXXXXXXXXXXXXXXXXX | sudo tee /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 uses: actions/setup-go@v3
with: with:
go-version: 1.20.1 go-version: ${{ matrix.go-version }}
id: go id: go
- name: "Check out CrowdSec repository" - name: "Check out CrowdSec repository"
@ -43,6 +47,18 @@ jobs:
fetch-depth: 0 fetch-depth: 0
submodules: true 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" - name: "Install bats dependencies"
env: env:
GOBIN: /usr/local/bin GOBIN: /usr/local/bin

View file

@ -22,18 +22,39 @@ on:
jobs: jobs:
build: build:
strategy:
matrix:
go-version: ["1.20.1"]
name: Build name: Build
runs-on: windows-2019 runs-on: windows-2019
steps: steps:
- name: Set up Go 1.20
- name: "Set up Go ${{ matrix.go-version }}"
uses: actions/setup-go@v3 uses: actions/setup-go@v3
with: with:
go-version: 1.20.1 go-version: ${{ matrix.go-version }}
id: go id: go
- name: Check out code into the Go module directory - name: Check out code into the Go module directory
uses: actions/checkout@v3 uses: actions/checkout@v3
with: with:
fetch-depth: 0 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 - name: Build
run: make windows_installer run: make windows_installer
- name: Upload MSI - name: Upload MSI

View file

@ -19,17 +19,20 @@ env:
CROWDSEC_FEATURE_DISABLE_HTTP_RETRY_BACKOFF: true CROWDSEC_FEATURE_DISABLE_HTTP_RETRY_BACKOFF: true
jobs: jobs:
build: build:
strategy:
matrix:
go-version: ["1.20.1"]
name: "Build + tests" name: "Build + tests"
runs-on: windows-2022 runs-on: windows-2022
steps: steps:
- name: "Set up Go 1.20" - name: "Set up Go ${{ matrix.go-version }}"
uses: actions/setup-go@v3 uses: actions/setup-go@v3
with: with:
go-version: 1.20.1 go-version: ${{ matrix.go-version }}
id: go id: go
- name: Check out CrowdSec repository - name: Check out CrowdSec repository
@ -38,6 +41,18 @@ jobs:
fetch-depth: 0 fetch-depth: 0
submodules: false 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 - name: Build
run: | run: |
make build make build

View file

@ -8,18 +8,36 @@ on:
jobs: jobs:
build: build:
strategy:
matrix:
go-version: ["1.20.1"]
name: Build and upload binary package name: Build and upload binary package
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Set up Go 1.20 - name: "Set up Go ${{ matrix.go-version }}"
uses: actions/setup-go@v3 uses: actions/setup-go@v3
with: with:
go-version: 1.20.1 go-version: ${{ matrix.go-version }}
id: go id: go
- name: Check out code into the Go module directory - name: Check out code into the Go module directory
uses: actions/checkout@v3 uses: actions/checkout@v3
with: with:
fetch-depth: 0 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 - name: Build the binaries
run: make release run: make release
- name: Upload to release - name: Upload to release
@ -28,19 +46,37 @@ jobs:
args: crowdsec-release.tgz application/x-gzip args: crowdsec-release.tgz application/x-gzip
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build_static: build_static:
strategy:
matrix:
go-version: ["1.20.1"]
name: Build and upload binary package name: Build and upload binary package
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Set up Go 1.20 - name: "Set up Go ${{ matrix.go-version }}"
uses: actions/setup-go@v3 uses: actions/setup-go@v3
with: with:
go-version: 1.20.1 go-version: ${{ matrix.go-version }}
id: go id: go
- name: Check out code into the Go module directory - name: Check out code into the Go module directory
uses: actions/checkout@v3 uses: actions/checkout@v3
with: with:
fetch-depth: 0 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 - name: Build the binaries
run: | run: |
make release BUILD_STATIC=yes make release BUILD_STATIC=yes

View file

@ -1,6 +1,6 @@
MIT License 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 Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal