yggdrasil-go/.github/workflows/ci.yml

269 lines
6.0 KiB
YAML
Raw Normal View History

2022-04-17 19:24:34 +03:00
name: Yggdrasil
on:
push:
pull_request:
release:
2022-04-17 19:53:55 +03:00
workflow_dispatch:
2022-04-17 19:24:34 +03:00
2022-04-18 12:30:40 +03:00
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
2022-04-17 19:24:34 +03:00
jobs:
2022-04-17 19:53:55 +03:00
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.18
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
args: --issues-exit-code=1
2022-04-18 12:33:33 +03:00
codeql:
name: Analyse
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: ["go"]
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
- name: Autobuild
uses: github/codeql-action/autobuild@v2
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
2022-04-17 19:53:55 +03:00
build-linux:
2022-04-17 19:24:34 +03:00
strategy:
2022-04-17 19:53:55 +03:00
fail-fast: false
2022-04-17 19:24:34 +03:00
matrix:
2022-04-17 20:22:26 +03:00
goversion: ["1.17", "1.18"]
2022-04-17 19:53:55 +03:00
name: Build & Test (Linux, Go ${{ matrix.goversion }})
needs: [lint]
2022-04-17 20:22:26 +03:00
2022-04-17 19:24:34 +03:00
runs-on: ubuntu-latest
steps:
2022-04-17 20:22:26 +03:00
- uses: actions/checkout@v3
2022-04-17 19:24:34 +03:00
2022-04-17 20:22:26 +03:00
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.goversion }}
2022-04-17 19:24:34 +03:00
2022-04-17 20:22:26 +03:00
- name: Build Yggdrasil
run: go build -v ./...
2022-04-17 19:24:34 +03:00
2022-04-17 20:22:26 +03:00
- name: Unit tests
run: go test -v ./...
2022-04-17 19:53:55 +03:00
build-windows:
strategy:
fail-fast: false
matrix:
2022-04-17 20:22:26 +03:00
goversion: ["1.17", "1.18"]
2022-04-17 19:53:55 +03:00
name: Build & Test (Windows, Go ${{ matrix.goversion }})
needs: [lint]
2022-04-17 20:22:26 +03:00
2022-04-17 19:53:55 +03:00
runs-on: windows-latest
steps:
2022-04-17 20:22:26 +03:00
- uses: actions/checkout@v3
2022-04-17 19:53:55 +03:00
2022-04-17 20:22:26 +03:00
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.goversion }}
- name: Build Yggdrasil
run: go build -v ./...
2022-04-17 19:53:55 +03:00
2022-04-17 20:22:26 +03:00
- name: Unit tests
run: go test -v ./...
2022-04-17 19:53:55 +03:00
build-macos:
strategy:
fail-fast: false
matrix:
2022-04-17 20:22:26 +03:00
goversion: ["1.17", "1.18"]
2022-04-17 19:53:55 +03:00
name: Build & Test (macOS, Go ${{ matrix.goversion }})
needs: [lint]
2022-04-17 20:22:26 +03:00
2022-04-17 19:53:55 +03:00
runs-on: macos-latest
steps:
2022-04-17 20:22:26 +03:00
- uses: actions/checkout@v3
2022-04-17 19:53:55 +03:00
2022-04-17 20:22:26 +03:00
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.goversion }}
2022-04-17 19:53:55 +03:00
2022-04-17 20:22:26 +03:00
- name: Build Yggdrasil
run: go build -v ./...
2022-04-17 19:53:55 +03:00
2022-04-17 20:22:26 +03:00
- name: Unit tests
run: go test -v ./...
2022-04-17 19:53:55 +03:00
tests-ok:
name: All tests passed
2022-04-18 12:33:33 +03:00
needs: [lint, codeql, build-linux, build-windows, build-macos]
2022-04-17 19:53:55 +03:00
runs-on: ubuntu-latest
if: ${{ !cancelled() }}
steps:
- name: Check all tests passed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
2022-04-18 01:38:16 +03:00
build-packages-debian:
strategy:
fail-fast: false
matrix:
pkgarch: ["amd64", "i386", "mips", "mipsel", "armhf", "armel", "arm64"]
name: Create Package (Debian, ${{ matrix.pkgarch }})
needs: [tests-ok]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18
- name: Build package
env:
PKGARCH: ${{ matrix.pkgarch }}
run: sh contrib/deb/generate.sh
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: Debian package (${{ matrix.pkgarch }})
path: "*.deb"
if-no-files-found: error
build-packages-macos:
strategy:
fail-fast: false
matrix:
pkgarch: ["amd64", "arm64"]
name: Create Package (macOS, ${{ matrix.pkgarch }})
needs: [tests-ok]
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18
- name: Build package
env:
PKGARCH: ${{ matrix.pkgarch }}
run: sh contrib/macos/create-pkg.sh
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: macOS package (${{ matrix.pkgarch }})
path: "*.pkg"
if-no-files-found: error
build-packages-windows:
strategy:
fail-fast: false
matrix:
pkgarch: ["x64", "x86", "arm", "arm64"]
name: Create Package (Windows, ${{ matrix.pkgarch }})
needs: [tests-ok]
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18
- name: Build package
run: sh contrib/msi/build-msi.sh ${{ matrix.pkgarch }}
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: Windows package (${{ matrix.pkgarch }})
path: "*.msi"
if-no-files-found: error
build-packages-router:
strategy:
fail-fast: false
matrix:
pkgarch: ["edgerouter-x", "edgerouter-lite", "vyos-amd64", "vyos-i386"]
name: Create Package (Router, ${{ matrix.pkgarch }})
needs: [tests-ok]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
path: yggdrasil
- uses: actions/checkout@v3
with:
repository: neilalexander/vyatta-yggdrasil
path: vyatta-yggdrasil
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18
- name: Build package
env:
BUILDDIR_YGG: /home/runner/work/yggdrasil-go/yggdrasil-go/yggdrasil
run: cd /home/runner/work/yggdrasil-go/yggdrasil-go/vyatta-yggdrasil && ./build-${{ matrix.pkgarch }}
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: Router package (${{ matrix.pkgarch }})
path: "/home/runner/work/yggdrasil-go/yggdrasil-go/vyatta-yggdrasil/*.deb"
if-no-files-found: error