Merge pull request #2602 from nspcc-dev/add-darwin-builds

Add darwin builds
This commit is contained in:
Roman Khimov 2022-07-21 15:08:59 +03:00 committed by GitHub
commit 7118b4f4ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 152 additions and 375 deletions

View file

@ -8,170 +8,142 @@ on:
paths-ignore: paths-ignore:
- 'scripts/**' - 'scripts/**'
- '**/*.md' - '**/*.md'
push:
# Build for the master branch.
branches:
- master
release:
# Publish released commit as Docker `latest` and `git_revision` images.
types:
- published
workflow_dispatch: workflow_dispatch:
inputs: inputs:
ref: ref:
description: 'Ref to build CLI for Ubuntu and Windows Server Core [default: latest master; examples: v0.92.0, 0a4ff9d3e4a9ab432fd5812eb18c98e03b5a7432]' description: 'Ref to build CLI for Ubuntu and Windows Server Core [default: latest master; examples: v0.92.0, 0a4ff9d3e4a9ab432fd5812eb18c98e03b5a7432]'
required: false required: false
default: '' default: ''
push_image:
description: 'Push images to DockerHub [default: false; examples: true, false]'
required: false
default: 'false'
use_latest_tag:
description: 'Use `latest` tag while pushing images to DockerHub (applied to Ubuntu image only) [default: false; examples: true, false]'
required: false
default: 'false'
env: env:
GO111MODULE: "on" GO111MODULE: "on"
jobs: jobs:
build_cli_ubuntu: build_cli:
name: Build CLI (Ubuntu) name: Build CLI
runs-on: ubuntu-20.04 runs-on: ${{matrix.os}}
strategy:
matrix:
os: [ubuntu-20.04, windows-2022, macos-12]
arch: [amd64, arm64]
exclude:
- os: windows-2022
arch: 'arm64'
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
with: with:
ref: ${{ github.event.inputs.ref }} ref: ${{ github.event.inputs.ref }}
# Allows to fetch all history for all branches and tags. Need this for proper versioning. # Allows to fetch all history for all branches and tags. Need this for proper versioning.
fetch-depth: 0 fetch-depth: 0
- name: Set up Go - name: Set up Go
uses: actions/setup-go@v2 uses: actions/setup-go@v3
with: with:
go-version: 1.18 go-version: 1.18
cache: true
- name: Restore Go modules from cache
uses: actions/cache@v2
with:
path: /home/runner/go/pkg/mod
key: deps-${{ hashFiles('go.sum') }}
- name: Update Go modules - name: Update Go modules
run: go mod download -json run: go mod download -json
- name: Build CLI - name: Build CLI
run: make build run: make build
env:
GOARCH: ${{ matrix.arch }}
- name: Upload artifact - name: Upload artifact
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v2
with: with:
name: neo-go-binaries-ubuntu name: neo-go-${{ matrix.os }}-${{ matrix.arch }}
path: ./bin/neo-go path: ./bin/neo-go*
if-no-files-found: error if-no-files-found: error
build_cli_wsc: build_image:
name: Build CLI (Windows Server Core) needs: build_cli
runs-on: windows-2022 name: Build and push docker image
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.inputs.ref }}
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18
- name: Restore Go modules from cache
uses: actions/cache@v2
with:
path: /home/runner/go/pkg/mod
key: deps-${{ hashFiles('go.sum') }}
- name: Update Go modules
run: go mod download -json
- name: Build CLI
run: make build
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: neo-go-binaries-wsc
path: ./bin/neo-go.exe
if-no-files-found: error
build_image_ubuntu:
needs: build_cli_ubuntu
name: Build Docker image (Ubuntu)
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
with: with:
ref: ${{ github.event.inputs.ref }} ref: ${{ github.event.inputs.ref }}
fetch-depth: 0 fetch-depth: 0
# For proper `deps` make target execution. - name: Set up QEMU
- name: Set up Go if: runner.os != 'Windows'
uses: actions/setup-go@v2 uses: docker/setup-qemu-action@v2
with:
go-version: 1.18
- name: Build Docker image - name: Set up Docker Buildx
run: make image uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Set vars
id: setvars
run: make gh-docker-vars
- name: Set latest tag
id: setlatest
if: ${{ (github.event_name == 'release' && github.event.release.target_commitish == 'master') || (github.event_name == 'workflow_dispatch' && github.event.inputs.push_image == 'true' && github.event.inputs.use_latest_tag == 'true') }}
run: echo "::set-output name=latest::,${{ steps.setvars.outputs.repo }}:latest"
- name: Build and push
uses: docker/build-push-action@v3
with:
push: ${{ github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.push_image == 'true') }}
platforms: linux/amd64,linux/arm64
build-args: |
REPO=${{ steps.setvars.outputs.repo }}
VERSION=${{ steps.setvars.outputs.version }}
tags: ${{ steps.setvars.outputs.repo }}:${{ steps.setvars.outputs.version }}${{ steps.setvars.outputs.suffix }}${{ steps.setlatest.outputs.latest }}
build_image_wsc: build_image_wsc:
needs: build_cli_wsc needs: build_cli
name: Build Docker image (Windows Server Core) name: Build and push docker image (Windows Server Core)
runs-on: windows-2022 runs-on: windows-2022
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
with: with:
ref: ${{ github.event.inputs.ref }} ref: ${{ github.event.inputs.ref }}
fetch-depth: 0 fetch-depth: 0
# For proper `deps` make target execution. # For proper `deps` make target execution.
- name: Set up Go - name: Set up Go
uses: actions/setup-go@v2 uses: actions/setup-go@v3
with: with:
go-version: 1.18 go-version: 1.18
cache: true
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build Docker image - name: Build Docker image
run: make image run: make image
build_privnet_image_ubuntu: - name: Push image to registry
needs: build_cli_ubuntu if: ${{ github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.push_image == 'true') }}
name: Build privnet Docker image (Ubuntu) run: make image-push
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.inputs.ref }}
fetch-depth: 0
# For proper `deps` make target execution.
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18
# For information purposes.
- name: Print Docker version
run: docker --version
- name: Build privnet Docker image
run: make env_image
build_privnet_image_wsc:
needs: build_cli_wsc
name: Build privnet Docker image (Windows Server Core)
runs-on: windows-2022
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.inputs.ref }}
fetch-depth: 0
# For proper `deps` make target execution.
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18
# For information purposes.
- name: Print Docker version
run: docker --version
- name: Build privnet Docker image
run: make env_image

View file

@ -1,67 +0,0 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
on:
push:
branches: [ master, master-2.x ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
schedule:
- cron: '35 8 * * 1'
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
language: [ 'go' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
steps:
- name: Checkout repository
uses: actions/checkout@v2
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
# Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
#- run: |
# make bootstrap
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2

View file

@ -1,169 +0,0 @@
name: Push images to DockerHub
# Controls when the action will run.
on:
push:
# Publish `master` as Docker `latest` and `git_revision` images.
branches:
- master
release:
# Publish released commit as Docker `latest` and `git_revision` images.
types:
- published
# Allows to run this workflow manually from the Actions tab.
workflow_dispatch:
inputs:
ref:
description: 'Ref to build Docker images for Ubuntu and Windows Server Core [default: latest master; examples: v0.92.0, 0a4ff9d3e4a9ab432fd5812eb18c98e03b5a7432]'
required: false
default: ''
push_image:
description: 'Push images to DockerHub [default: false; examples: true, false]'
required: false
default: 'false'
use_latest_tag:
description: 'Use `latest` tag while pushing images to DockerHub (applied to Ubuntu image only) [default: false; examples: true, false]'
required: false
default: 'false'
# Environment variables.
env:
GO111MODULE: "on"
# A workflow run.
jobs:
tests_ubuntu:
name: Run Ubuntu-based tests before publishing
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.inputs.ref }}
# Allows to fetch all history for all branches and tags. Need this for proper versioning.
fetch-depth: 0
- name: Sync VM submodule
run: |
git submodule sync
git submodule update --init
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18
- name: Restore go modules from cache
uses: actions/cache@v2
with:
path: /home/runner/go/pkg/mod
key: deps-${{ hashFiles('go.sum') }}
- name: Update Go modules
run: go mod download -json
- name: Run tests
run: make test
publish_ubuntu:
# Ensure test job passes before pushing image.
needs: tests_ubuntu
name: Publish Ubuntu-based image to DockerHub
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.inputs.ref }}
# Allows to fetch all history for all branches and tags. Need this for proper versioning.
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18
- name: Build image
run: make image
- name: Build image with 'latest' tag
if: ${{ (github.event_name == 'release' && github.event.release.target_commitish == 'master') || (github.event_name == 'workflow_dispatch' && github.event.inputs.push_image == 'true' && github.event.inputs.use_latest_tag == 'true') }}
run: make image-latest
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Push image to registry
if: ${{ github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.push_image == 'true') }}
run: make image-push
- name: Push image with 'latest' tag to registry
if: ${{ (github.event_name == 'release' && github.event.release.target_commitish == 'master') || (github.event_name == 'workflow_dispatch' && github.event.inputs.push_image == 'true' && github.event.inputs.use_latest_tag == 'true') }}
run: make image-push-latest
tests_wsc:
name: Run WindowsServerCore-based tests before publishing
runs-on: windows-2022
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.inputs.ref }}
# Allows to fetch all history for all branches and tags. Need this for proper versioning.
fetch-depth: 0
- name: Sync VM submodule
run: |
git submodule sync
git submodule update --init
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18
- name: Restore go modules from cache
uses: actions/cache@v2
with:
path: /home/runner/go/pkg/mod
key: deps-${{ hashFiles('go.sum') }}
- name: Update Go modules
run: go mod download -json
- name: Run tests
run: make test
publish_wsc:
# Ensure test job passes before pushing image.
needs: tests_wsc
name: Publish WindowsServerCore-based image to DockerHub
runs-on: windows-2022
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.inputs.ref }}
# Allows to fetch all history for all branches and tags. Need this for proper versioning.
fetch-depth: 0
- name: Show docker images
run: docker images
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18
- name: Build image
run: make image
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Push image to registry
if: ${{ github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.push_image == 'true') }}
run: make image-push

View file

@ -1,6 +1,8 @@
name: Tests name: Tests
on: on:
push:
branches: [ master ]
pull_request: pull_request:
branches: branches:
- master - master
@ -19,7 +21,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: golangci-lint - name: golangci-lint
uses: golangci/golangci-lint-action@v2 uses: golangci/golangci-lint-action@v2
with: with:
@ -30,13 +32,58 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Check dependencies - name: Check dependencies
run: | run: |
./scripts/check_deps.sh ./scripts/check_deps.sh
codeql:
name: CodeQL
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
language: [ 'go' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
steps:
- name: Checkout repository
uses: actions/checkout@v3
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
# Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
#- run: |
# make bootstrap
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
test_cover: test_cover:
name: Coverage name: Coverage
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
@ -44,7 +91,7 @@ jobs:
env: env:
CGO_ENABLED: 0 CGO_ENABLED: 0
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
with: with:
fetch-depth: 0 fetch-depth: 0
@ -54,15 +101,10 @@ jobs:
git submodule update --init git submodule update --init
- name: Set up Go - name: Set up Go
uses: actions/setup-go@v2 uses: actions/setup-go@v3
with: with:
go-version: 1.18 go-version: 1.18
cache: true
- name: Restore Go modules from cache
uses: actions/cache@v2
with:
path: /home/runner/go/pkg/mod
key: deps-${{ hashFiles('go.sum') }}
- name: Update Go modules - name: Update Go modules
run: go mod download -json run: go mod download -json
@ -82,33 +124,32 @@ jobs:
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
strategy: strategy:
matrix: matrix:
os: [ubuntu-20.04, windows-2022] os: [ubuntu-20.04, windows-2022, macos-12]
go_versions: [ '1.16', '1.17', '1.18' ] go_versions: [ '1.16', '1.17', '1.18' ]
exclude: exclude:
# Only latest Go version for Windows. # Only latest Go version for Windows and MacOS.
- os: windows-2022 - os: windows-2022
go_versions: '1.16' go_versions: '1.16'
- os: windows-2022 - os: windows-2022
go_versions: '1.17' go_versions: '1.17'
- os: macos-12
go_versions: '1.16'
- os: macos-12
go_versions: '1.17'
# Exclude latest Go version for Ubuntu as Coverage uses it. # Exclude latest Go version for Ubuntu as Coverage uses it.
- os: ubuntu-20.04 - os: ubuntu-20.04
go_versions: '1.18' go_versions: '1.18'
fail-fast: false fail-fast: false
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Set up Go - name: Set up Go
uses: actions/setup-go@v2 uses: actions/setup-go@v3
with: with:
go-version: '${{ matrix.go_versions }}' go-version: '${{ matrix.go_versions }}'
cache: true
- name: Restore Go modules from cache
uses: actions/cache@v2
with:
path: /home/runner/go/pkg/mod
key: deps-${{ hashFiles('go.sum') }}
- name: Update Go modules - name: Update Go modules
run: go mod download -json run: go mod download -json

View file

@ -24,8 +24,8 @@ IMAGE_REPO=nspccdev/neo-go
# All of the targets are phony here because we don't really use make dependency # All of the targets are phony here because we don't really use make dependency
# tracking for files # tracking for files
.PHONY: build $(BINARY) deps image docker/$(BINARY) image-latest image-push image-push-latest check-version clean-cluster push-tag \ .PHONY: build $(BINARY) deps image docker/$(BINARY) image-latest image-push image-push-latest clean-cluster \
test vet lint fmt cover test vet lint fmt cover version gh-docker-vars
build: deps build: deps
@echo "=> Building binary" @echo "=> Building binary"
@ -86,20 +86,20 @@ image-push-latest:
@echo "=> Publish image for Ubuntu with 'latest' tag" @echo "=> Publish image for Ubuntu with 'latest' tag"
@docker push $(IMAGE_REPO):latest @docker push $(IMAGE_REPO):latest
check-version:
git fetch && (! git rev-list ${VERSION})
deps: deps:
@CGO_ENABLED=0 \ @CGO_ENABLED=0 \
go mod download go mod download
@CGO_ENABLED=0 \ @CGO_ENABLED=0 \
go mod tidy -v go mod tidy -v
push-tag: version:
git checkout ${BRANCH} @echo $(VERSION)
git pull origin ${BRANCH}
git tag ${VERSION} gh-docker-vars:
git push origin ${VERSION} @echo "::set-output name=file::$(D_FILE)"
@echo "::set-output name=version::$(VERSION)"
@echo "::set-output name=repo::$(REPO)"
@echo "::set-output name=suffix::$(IMAGE_SUFFIX)"
test: test:
@go test ./... -cover @go test ./... -cover