diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index ec07c46..92a0e67 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,29 +1,29 @@ name: Build binaries on: + pull_request: push: + branches: + - "main" tags: - "v*" jobs: - linux: + build: + name: Build binaries for ${{ matrix.platform.name }}-${{ matrix.arch }} strategy: fail-fast: false matrix: arch: - arm64 - amd64 - name: Build binaries for linux platform - runs-on: ubuntu-20.04 + platform: + - name: linux + os: ubuntu-20.04 + - name: darwin + os: macos-latest + runs-on: ${{ matrix.platform.os }} steps: - - name: Set up go - id: go - uses: actions/setup-go@v3 - with: - go-version: 1.17 - - name: Export platform env - run: | - echo "GOARCH=${{ matrix.arch }}" >> $GITHUB_ENV - name: Check out code uses: actions/checkout@v3 with: @@ -32,80 +32,26 @@ jobs: # for ref value discussion ref: ${{ github.event.pull_request.head.sha }} - - name: Restore go package cache - id: cache-go-mod - uses: actions/cache@v3 - with: - path: | - ~/.cache/go-build - ~/go/pkg/mod - key: ${{ runner.os }}-${{ matrix.arch }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-${{ matrix.arch }}-go- - - - name: Download dependencies - if: steps.cache-go-mod.outputs.cache-hit != 'true' - run: go mod download - - - name: Build - run: | - mkdir -p build/ releases/ - make - cd build/ - mv catalyst-uploader livepeer-catalyst-uploader - tar -czvf "../releases/livepeer-catalyst-uploader-linux-${GOARCH}.tar.gz" ./livepeer-catalyst-uploader - - - name: Upload artifacts for processing further in linux - uses: actions/upload-artifact@master - with: - name: release-artifacts - path: releases/ - - macos: - strategy: - fail-fast: false - matrix: - arch: - - arm64 - - amd64 - name: Build binaries for macOS platform - runs-on: macos-11 - steps: - name: Set up go id: go uses: actions/setup-go@v3 with: - go-version: 1.17 + go-version-file: go.mod + cache: true + cache-dependency-path: go.sum + - name: Export platform env run: | echo "GOARCH=${{ matrix.arch }}" >> $GITHUB_ENV - - name: Check out code - uses: actions/checkout@v3 - with: - fetch-depth: 0 - # Check https://github.com/livepeer/go-livepeer/pull/1891 - # for ref value discussion - ref: ${{ github.event.pull_request.head.sha }} - - - name: Restore go package cache - id: cache-go-mod - uses: actions/cache@v3 - with: - path: | - ~/.cache/go-build - ~/go/pkg/mod - key: ${{ runner.os }}-${{ matrix.arch }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-${{ matrix.arch }}-go- + echo "GOOS=${{ matrix.platform.name }}" >> $GITHUB_ENV - name: Download dependencies - if: steps.cache-go-mod.outputs.cache-hit != 'true' + if: steps.go.outputs.cache-hit != 'true' run: go mod download - name: Build run: | mkdir -p build/ releases/ - export PKG_CONFIG_PATH=~/compiled/lib/pkgconfig make cd build/ mv catalyst-uploader livepeer-catalyst-uploader @@ -117,7 +63,7 @@ jobs: regex: '^(master|main|v[0-9]+\.\d+\.\d+)$' - name: Codesign and notarize binaries - if: ${{ steps.match-tag.outputs.match != '' }} + if: ${{ matrix.platform.name == 'darwin' && steps.match-tag.outputs.match != '' }} uses: livepeer/action-gh-codesign-apple@latest with: developer-certificate-id: ${{ secrets.CI_MACOS_CERTIFICATE_ID }} @@ -125,16 +71,69 @@ jobs: developer-certificate-password: ${{ secrets.CI_MACOS_CERTIFICATE_PASSWORD }} app-notarization-email: ${{ secrets.CI_MACOS_NOTARIZATION_USER }} app-notarization-password: ${{ secrets.CI_MACOS_NOTARIZATION_PASSWORD }} - binary-path: "build/livepeer-catalyst-uploader" - app-bundle-id: "org.livepeer.catalyst-uploader" + binary-path: build/livepeer-catalyst-uploader + app-bundle-id: org.livepeer.catalyst-uploader - - name: Archive signed binary + - name: Archive binaries run: | cd build/ - tar -czvf "../releases/livepeer-catalyst-uploader-darwin-${GOARCH}.tar.gz" ./livepeer-catalyst-uploader + tar -czvf "../releases/livepeer-catalyst-uploader-${GOOS}-${GOARCH}.tar.gz" ./livepeer-catalyst-uploader - name: Upload artifacts for processing further in linux - uses: actions/upload-artifact@master + uses: actions/upload-artifact@v3 with: name: release-artifacts path: releases/ + + upload: + name: Upload artifacts to google bucket + permissions: + contents: "read" + id-token: "write" + runs-on: ubuntu-latest + needs: + - build + steps: + - name: Download artifacts + uses: actions/download-artifact@v3 + with: + name: release-artifacts + path: releases/ + + - name: Generate sha256 checksum and gpg signatures for release artifacts + uses: livepeer/action-gh-checksum-and-gpg-sign@latest + with: + artifacts-dir: releases + release-name: ${{ github.ref_type == 'tag' && github.ref_name || github.sha }} + gpg-key: ${{ secrets.CI_GPG_SIGNING_KEY }} + gpg-key-passphrase: ${{ secrets.CI_GPG_SIGNING_PASSPHRASE }} + + - name: Generate branch manifest + id: branch-manifest + uses: livepeer/branch-manifest-action@latest + with: + project-name: ${{ github.event.repository.name }} + platform: linux, darwin + + - name: Authenticate to Google Cloud + id: auth + uses: google-github-actions/auth@v0 + with: + workload_identity_provider: ${{ secrets.CI_GOOGLE_WORKLOAD_IDENTITY_PROVIDER }} + service_account: ${{ secrets.CI_GOOGLE_SERVICE_ACCOUNT }} + + - name: Upload release archives to Google Cloud + id: upload-archives + uses: google-github-actions/upload-cloud-storage@v0 + with: + path: 'releases' + destination: "build.livepeer.live/${{ github.event.repository.name }}/${{ (github.ref_type == 'tag' && github.ref_name) || github.sha }}" + parent: false + + - name: Upload branch manifest file + id: upload-manifest + uses: google-github-actions/upload-cloud-storage@v0 + with: + path: ${{ steps.branch-manifest.outputs.manifest-file }} + destination: 'build.livepeer.live/${{ github.event.repository.name }}/' + parent: false diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index ae8cd22..efe3026 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -43,6 +43,13 @@ jobs: go fmt ./... git diff --exit-code - - name: Run tests + - name: Run tests with coverage run: | - go test ./... + go test ./... --race --covermode=atomic --coverprofile=coverage.out + + - name: Upload coverage reports + uses: codecov/codecov-action@v3 + with: + files: ./coverage.out + name: ${{ github.event.repository.name }} + verbose: true diff --git a/go.mod b/go.mod index 44b8deb..754f5fd 100644 --- a/go.mod +++ b/go.mod @@ -3,12 +3,10 @@ module github.com/livepeer/catalyst-uploader go 1.17 require ( - cloud.google.com/go/storage v1.24.0 - github.com/aws/aws-sdk-go v1.44.64 github.com/google/uuid v1.3.0 + github.com/livepeer/go-tools v0.0.0-20220811104423-080e77013571 github.com/sirupsen/logrus v1.8.1 github.com/stretchr/testify v1.8.0 - google.golang.org/api v0.89.0 gopkg.in/natefinch/lumberjack.v2 v2.0.0 ) @@ -16,7 +14,9 @@ require ( cloud.google.com/go v0.102.1 // indirect cloud.google.com/go/compute v1.7.0 // indirect cloud.google.com/go/iam v0.3.0 // indirect + cloud.google.com/go/storage v1.24.0 // indirect github.com/BurntSushi/toml v1.2.0 // indirect + github.com/aws/aws-sdk-go v1.44.64 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect github.com/golang/protobuf v1.5.2 // indirect @@ -24,8 +24,7 @@ require ( github.com/googleapis/enterprise-certificate-proxy v0.1.0 // indirect github.com/googleapis/gax-go/v2 v2.4.0 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect - github.com/kr/text v0.2.0 // indirect - github.com/livepeer/go-tools v0.0.0-20220811104423-080e77013571 // indirect + github.com/kr/pretty v0.2.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/stretchr/objx v0.4.0 // indirect go.opencensus.io v0.23.0 // indirect @@ -34,11 +33,10 @@ require ( golang.org/x/sys v0.0.0-20220624220833-87e55d714810 // indirect golang.org/x/text v0.3.7 // indirect golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f // indirect + google.golang.org/api v0.89.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/genproto v0.0.0-20220624142145-8cd45d7dbd1f // indirect google.golang.org/grpc v1.47.0 // indirect google.golang.org/protobuf v1.28.0 // indirect - gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect - gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index b8606dc..0949a1e 100644 --- a/go.sum +++ b/go.sum @@ -207,8 +207,6 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/livepeer/go-tools v0.0.0-20220805063103-76df6beb6506 h1:qKon23c1RQPvL5Oya/hkImbaXNMkt6VdYtnh5jcIhoY= -github.com/livepeer/go-tools v0.0.0-20220805063103-76df6beb6506/go.mod h1:aLVS1DT0ur9kpr0IlNI4DNcm9vVjRRUjDnwuEUm0BdQ= github.com/livepeer/go-tools v0.0.0-20220811104423-080e77013571 h1:uRIy3pBd1fV5xfKUwOBDbb3gt6RsB0T+YHLc+EFYyNE= github.com/livepeer/go-tools v0.0.0-20220811104423-080e77013571/go.mod h1:aLVS1DT0ur9kpr0IlNI4DNcm9vVjRRUjDnwuEUm0BdQ= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=