Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: fix CI and factorize install #309

Merged
merged 2 commits into from
Nov 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/actions/install/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: 'Thyra install'

inputs:
os:
required: true
default: 'ubuntu-latest'

runs:
using: "composite"
steps:
- uses: actions/setup-go@v3
env:
GO_VERSION: 1.19
with:
go-version: ${{ env.GO_VERSION }}
- name: installing linux dependencies
if: ${{ inputs.os == 'ubuntu-latest' }}
shell: bash
run: |
sudo apt update
sudo apt install -y libgl1-mesa-dev xorg-dev gcc-mingw-w64-x86-64
- name: Install Xcode
if: ${{ inputs.os == 'macos-latest' }}
uses: devbotsxyz/xcode-select@v1
65 changes: 26 additions & 39 deletions .github/workflows/CD.yml → .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,28 @@
name: CD

name: build and upload artifacts
on:
workflow_dispatch:
inputs:
release-version:
description: "Version to produce"
required: true
release-as-draft:
description: "Whether it's a draft or not"
required: true
type: boolean
default: true
release-as-prerelease:
description: "Whether it's a prerelease or not"
required: true
type: boolean
default: false
generate-release-notes:
description: "Generate release notes"
required: true
type: boolean
default: true
push:
tags:
- v[0-9]+.*
branches:
- main
pull_request:
workflow_call:

env:
GO_VERSION: 1.19
RELEASE_VERSION: ${{ github.event.inputs.release-version }}
RELEASE_AS_DRAFT: ${{ github.event.inputs.release-as-draft }}
RELEASE_AS_PRERELEASE: ${{ github.event.inputs.release-as-prerelease }}
GENERATE_RELEASE_NOTES: ${{ github.event.inputs.generate-release-notes }}
permissions:
contents: read

jobs:
build-release:
name: create release with assets

lint:
uses: ./.github/workflows/lint.yml

tests:
uses: ./.github/workflows/tests.yml

build:
if: ${{ github.ref == 'refs/heads/main' }}
needs: [lint, tests]
name: build and upload artifacts
strategy:
matrix:
include:
Expand All @@ -55,18 +46,13 @@ jobs:
target: darwin
cc: ""
cxx: ""
runs-on: ${{ matrix.os }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: installing dependencies
if: startsWith(matrix.os, 'ubuntu-')
run: sudo apt update && sudo apt install -y libgl1-mesa-dev xorg-dev gcc-mingw-w64-x86-64
- name: Select the latest version of Xcode
if: startsWith(matrix.os, 'macos-')
uses: devbotsxyz/xcode-select@v1
- uses: actions/setup-go@v3
uses: ./.github/actions/install
with:
go-version: ${{ env.GO_VERSION }}
- uses: actions/checkout@v3
os: ${{ matrix.os }}
- name: Build binary for ${{ matrix.target }} on ${{ matrix.arch}}
run: GOOS=${{ matrix.target }} GOARCH=${{ matrix.arch }} CGO_ENABLED=1 CC=${{ matrix.cc }} CXX=${{ matrix.cxx }} go build -o thyra-server_${{ matrix.target }}_${{ matrix.arch }} ./cmd/thyra-server/
- name: Upload artifacts
Expand All @@ -75,6 +61,7 @@ jobs:
name: ${{ matrix.target }}-${{ matrix.arch }}-binary
path: thyra-server_${{ matrix.target }}_${{ matrix.arch }}
- name: Create release and upload binaries
if: ${{ env.RELEASE_VERSION != '' }}
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ env.RELEASE_VERSION }}
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
on:
push:
branches: [ main ]
pull_request:
workflow_call:

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/install
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
args: --timeout=3m
33 changes: 33 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Release workflow

on:
workflow_dispatch:
inputs:
release-version:
description: "Version to produce"
required: true
release-as-draft:
description: "Whether it's a draft or not"
required: true
type: boolean
default: true
release-as-prerelease:
description: "Whether it's a prerelease or not"
required: true
type: boolean
default: false
generate-release-notes:
description: "Generate release notes"
required: true
type: boolean
default: true

env:
RELEASE_VERSION: ${{ github.event.inputs.release-version }}
RELEASE_AS_DRAFT: ${{ github.event.inputs.release-as-draft }}
RELEASE_AS_PRERELEASE: ${{ github.event.inputs.release-as-prerelease }}
GENERATE_RELEASE_NOTES: ${{ github.event.inputs.generate-release-notes }}

jobs:
build-release:
uses: ./.github/workflows/build.yml
16 changes: 16 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
on:
push:
branches: [ main ]
pull_request:
workflow_call:

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/install
- run: go test ./... -coverprofile=coverage.coverprofile
- uses: codecov/codecov-action@v3
with:
files: coverage.coverprofile