Skip to content

Commit

Permalink
Merge pull request #17 from buty4649/improve-ci
Browse files Browse the repository at this point in the history
  • Loading branch information
buty4649 authored Jun 3, 2023
2 parents 5581274 + a075f05 commit c560b71
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 69 deletions.
103 changes: 34 additions & 69 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ on:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
os: [linux, darwin, windows]
arch: [amd64]
include:
- os: windows
suffix: .exe
exclude:
- os: windows
arch: arm64
steps:
- uses: actions/checkout@v3
- name: Login to Docker Hub
Expand All @@ -18,94 +28,49 @@ jobs:
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2
bundler-cache: true
- name: Build cache
uses: actions/cache@v3
with:
path: build/cache
key: ${{ runner.os }}-ccache
key: ${{ matrix.os }}-${{ matrix.arch }}-ccache
- name: build
run: rake build:all
run: rake build:${{ matrix.os }}-${{ matrix.arch }}

- name: Upload test binary (linux-amd64)
- name: Upload test binary (${{ matrix.os }}-${{ matrix.arch }}})
uses: actions/upload-artifact@v3
with:
name: rf-${{ github.sha }}-linux-amd64
path: build/linux-amd64/bin/rf
- name: Upload test binary (linux-arm64)
uses: actions/upload-artifact@v3
with:
name: rf-${{ github.sha }}-linux-arm64
path: build/linux-arm64/bin/rf
- name: Upload test binary (darwin-amd64)
uses: actions/upload-artifact@v3
with:
name: rf-${{ github.sha }}-darwin-amd64
path: build/darwin-amd64/bin/rf
- name: Upload test binary (darwin-arm64)
uses: actions/upload-artifact@v3
with:
name: rf-${{ github.sha }}-darwin-arm64
path: build/darwin-arm64/bin/rf
- name: Upload test binary (windows-amd64)
uses: actions/upload-artifact@v3
with:
name: rf-${{ github.sha }}-windows-amd64
path: build/windows-amd64/bin/rf.exe

test-on-linux:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: rf-${{ github.sha }}-linux-amd64
path: build/bin
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2
- name: Install dependencies
run: bundle install
- name: Run test
run: |
chmod +x build/bin/rf
rake spec
test-on-macos:
needs: build
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: rf-${{ github.sha }}-darwin-amd64
path: build/bin
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2
- name: Install dependencies
run: bundle install
- name: Run test
run: |
chmod +x build/bin/rf
rake spec
name: rf-${{ github.sha }}-${{ matrix.os }}-${{ matrix.arch }}
path: build/${{ matrix.os }}-${{ matrix.arch }}/bin/rf${{ matrix.suffix }}

test-on-windows:
test:
needs: build
runs-on: windows-latest
strategy:
matrix:
runs-on: [ubuntu-latest, macos-latest, windows-latest]
include:
- runs-on: ubuntu-latest
os-arch: linux-amd64
- runs-on: macos-latest
os-arch: darwin-amd64
- runs-on: windows-latest
os-arch: windows-amd64
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: rf-${{ github.sha }}-windows-amd64
name: rf-${{ github.sha }}-${{ matrix.os-arch }}
path: build/bin
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2
bundler-cache: true
- name: Install dependencies
run: bundle install
- name: Grant execute permission
if: ${{ ! contains(matrix.runs-on, 'windows') }}
run: chmod +x build/bin/rf
- name: Run test
run: rake spec
run: bundle exec rake spec
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ GEM
parser (>= 3.2.0)

PLATFORMS
x64-mingw-ucrt
x86_64-darwin-20
x86_64-linux

DEPENDENCIES
Expand Down

0 comments on commit c560b71

Please sign in to comment.