| 1 | name: Build |
| 2 | on: [push, pull_request] |
| 3 | jobs: |
| 4 | linux: |
| 5 | runs-on: ubuntu-20.04 |
| 6 | steps: |
| 7 | - name: Checkout |
| 8 | uses: actions/checkout@v3 |
| 9 | - name: Setup Go |
| 10 | uses: actions/setup-go@v3 |
| 11 | with: |
| 12 | go-version: "1.20" |
| 13 | - name: Restore cache |
| 14 | uses: actions/cache@v3 |
| 15 | with: |
| 16 | path: | |
| 17 | ~/.cache/go-build |
| 18 | ~/go/pkg/mod |
| 19 | key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} |
| 20 | restore-keys: | |
| 21 | ${{ runner.os }}-go- |
| 22 | |
| 23 | - name: Build clients |
| 24 | run: | |
| 25 | source scripts/ci-set-ldflags.sh |
| 26 | export CGO_ENABLED=0 |
| 27 | GOOS=linux GOARCH=amd64 go build -ldflags "$ldflags" -tags clientonly -o build/relic-client-linux-amd64 |
| 28 | GOOS=linux GOARCH=arm64 go build -ldflags "$ldflags" -tags clientonly -o build/relic-client-linux-arm64 |
| 29 | GOOS=linux GOARCH=ppc64le go build -ldflags "$ldflags" -tags clientonly -o build/relic-client-linux-ppc64le |
| 30 | GOOS=freebsd GOARCH=amd64 go build -ldflags "$ldflags" -tags clientonly -o build/relic-client-freebsd-amd64 |
| 31 | |
| 32 | - name: Build server |
| 33 | run: CGO_ENABLED=1 go build -ldflags "$ldflags" -o build/relic-linux-amd64 |
| 34 | |
| 35 | - name: Unit tests |
| 36 | run: go test ./... |
| 37 | |
| 38 | - name: Functional tests |
| 39 | run: | |
| 40 | sudo apt-get update |
| 41 | sudo apt-get install curl softhsm2 zip |
| 42 | sed -i -e 's#provider:.*#provider: /usr/lib/softhsm/libsofthsm2.so#' functest/testconf.yml |
| 43 | ./functest/functest.sh |
| 44 | |
| 45 | - name: Save artifacts |
| 46 | uses: actions/upload-artifact@v3 |
| 47 | with: |
| 48 | name: linux |
| 49 | path: build/ |
| 50 | |
| 51 | darwin: |
| 52 | runs-on: macos-11 |
| 53 | steps: |
| 54 | - name: Checkout |
| 55 | uses: actions/checkout@v3 |
| 56 | - name: Setup Go |
| 57 | uses: actions/setup-go@v3 |
| 58 | with: |
| 59 | go-version: "1.20" |
| 60 | - name: Restore cache |
| 61 | uses: actions/cache@v3 |
| 62 | with: |
| 63 | path: | |
| 64 | ~/Library/Caches/go-build |
| 65 | ~/go/pkg/mod |
| 66 | key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} |
| 67 | restore-keys: | |
| 68 | ${{ runner.os }}-go- |
| 69 | |
| 70 | - name: Build client |
| 71 | run: | |
| 72 | source scripts/ci-set-ldflags.sh |
| 73 | export CGO_ENABLED=0 |
| 74 | GOARCH=amd64 go build -ldflags "$ldflags" -tags clientonly -o build/relic-client-darwin-amd64 |
| 75 | GOARCH=arm64 go build -ldflags "$ldflags" -tags clientonly -o build/relic-client-darwin-arm64 |
| 76 | |
| 77 | - name: Build server |
| 78 | run: | |
| 79 | export CGO_ENABLED=1 |
| 80 | GOARCH=amd64 go build -ldflags "$ldflags" -o build/relic-darwin-amd64 |
| 81 | GOARCH=arm64 go build -ldflags "$ldflags" -o build/relic-darwin-arm64 |
| 82 | |
| 83 | - name: Save artifacts |
| 84 | uses: actions/upload-artifact@v3 |
| 85 | with: |
| 86 | name: darwin |
| 87 | path: build/ |
| 88 | |
| 89 | windows: |
| 90 | runs-on: windows-2019 |
| 91 | defaults: |
| 92 | run: |
| 93 | shell: bash |
| 94 | steps: |
| 95 | - name: Checkout |
| 96 | uses: actions/checkout@v3 |
| 97 | - name: Setup Go |
| 98 | uses: actions/setup-go@v3 |
| 99 | with: |
| 100 | go-version: "1.20" |
| 101 | - name: Restore cache |
| 102 | uses: actions/cache@v3 |
| 103 | with: |
| 104 | path: | |
| 105 | %LocalAppData%\go-build |
| 106 | ~/go/pkg/mod |
| 107 | key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} |
| 108 | restore-keys: | |
| 109 | ${{ runner.os }}-go- |
| 110 | |
| 111 | - name: Build client |
| 112 | run: | |
| 113 | source scripts/ci-set-ldflags.sh |
| 114 | CGO_ENABLED=0 go build -ldflags "$ldflags" -tags clientonly -o build/relic-client-windows-amd64.exe |
| 115 | |
| 116 | - name: Build server |
| 117 | run: CGO_ENABLED=1 go build -ldflags "$ldflags" -o build/relic-windows-amd64.exe |
| 118 | |
| 119 | - name: Save artifacts |
| 120 | uses: actions/upload-artifact@v3 |
| 121 | with: |
| 122 | name: windows |
| 123 | path: build/ |