Skip to content

Commit

Permalink
Merge pull request #1 from evgkrsk/improve-ci
Browse files Browse the repository at this point in the history
Improve CI pipeline
  • Loading branch information
evgkrsk authored Jun 19, 2021
2 parents 64fe4fc + 5030990 commit 5f49754
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 14 deletions.
52 changes: 38 additions & 14 deletions .github/workflows/crystal.yml → .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,24 @@
name: Crystal CI
name: Release workflow

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
tags:
- 'v*'

jobs:
build:
build-linux-static:

runs-on: ubuntu-latest

container:
image: crystallang/crystal:1.0.0-alpine
image: crystallang/crystal:latest-alpine

steps:
- uses: actions/checkout@v2
- name: Install packages
run: apk --update --no-cache add upx
- name: Install dependencies
run: shards install
- name: Run ameba
run: crystal bin/ameba.cr
- name: Check format
run: crystal tool format --check
- name: Run tests
run: crystal spec
run: shards install --production
- name: Build
run: shards build --release --static --stats --progress --no-debug
- name: Strip
Expand All @@ -35,8 +28,30 @@ jobs:
with:
name: reqs-up-linux-static
path: ./bin/reqs-up

build-macos:
runs-on: macos-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Crystal
uses: crystal-lang/install-crystal@v1
- name: Install packages
run: brew install upx
- name: Install dependencies
run: shards install --production
- name: Build the binary
run: shards build --release --stats --progress --no-debug
- name: Compress binary
run: upx -9 bin/reqs-up
- name: Upload a Build Artifact
uses: actions/upload-artifact@v2
with:
name: reqs-up-macos
path: ./bin/reqs-up

release:
needs: [build]
needs: [build-linux-static, build-macos]
runs-on: ubuntu-latest
steps:
- name: Download artifacts
Expand All @@ -62,3 +77,12 @@ jobs:
asset_path: ./artifacts/reqs-up-linux-static/reqs-up
asset_name: reqs-up-linux-static
asset_content_type: application/binary
- name: Attach macOS binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./artifacts/reqs-up-macos/reqs-up
asset_name: reqs-up-macos
asset_content_type: application/binary
36 changes: 36 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Test workflow

on:
push:
branches:
- '**'
pull_request:
branches: [master]

jobs:
test:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2
- uses: crystal-lang/install-crystal@v1
- name: Cache shards
uses: actions/cache@v2
with:
path: lib
key: ${{ runner.os }}-shards-${{ hashFiles('**/shard.lock') }}
restore-keys: ${{ runner.os }}-shards-
- name: Install shards
run: shards check || shards install
- name: Run ameba
run: crystal bin/ameba.cr
- name: Check format
run: crystal tool format --check
- name: Run tests
run: crystal spec --order=random --error-on-warnings
- name: Build
run: shards build --stats --progress

0 comments on commit 5f49754

Please sign in to comment.