Skip to content

Commit

Permalink
Merge pull request #221 from cosmtrek/add_smoke_test
Browse files Browse the repository at this point in the history
add smoke support for file change in macOS, windows, ubuntu
  • Loading branch information
xiantang authored Nov 28, 2021
2 parents 3707f68 + f4dbae5 commit eb64223
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 27 deletions.
39 changes: 12 additions & 27 deletions .github/workflows/smoke_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,15 @@ on:
branches: [ master ]

jobs:
smoke_test:
name: smoke_test
runs-on: ubuntu-latest
steps:
- name: check out code
uses: actions/checkout@v2
- name: setup Go 1.16
id: go
uses: actions/setup-go@v2
with:
go-version: ^1.16
- name: install
run: make install
- name: check rebuild
id: check_rebuild
working-directory: ./smoke_test/check_rebuild
run: |
nohup air > nohup.out 2> nohup.err < /dev/null &
sleep 5
echo "" >> main.go
sleep 3
grep "running" nohup.out | wc -l | if [ "$(cat -)" -eq "2" ]; then echo "::set-output name=value::PASS"; else echo "::set-output name=value::FAIL"; fi
- uses: nick-invision/assert-action@v1
with:
expected: "PASS"
actual: ${{ steps.check_rebuild.outputs.value }}

smoke_test_ubuntu:
uses: cosmtrek/air/.github/workflows/smoke_test_reuse_job.yml@add_smoke_test
with:
run_on: ubuntu-latest
smoke_test_macos:
uses: cosmtrek/air/.github/workflows/smoke_test_reuse_job.yml@add_smoke_test
with:
run_on: macos-latest
smoke_test_windows:
uses: cosmtrek/air/.github/workflows/smoke_test_window_reust_job.yml@add_smoke_test
with:
run_on: windows-latest
37 changes: 37 additions & 0 deletions .github/workflows/smoke_test_reuse_job.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Reusable smoke_test

on:
workflow_call:
inputs:
run_on:
required: true
type: string

jobs:
smoke_test:
name: smoke_test
runs-on: ${{ inputs.run_on }}
steps:
- name: check out code
uses: actions/checkout@v2
- name: setup Go 1.16
id: go
uses: actions/setup-go@v2
with:
go-version: ^1.16
- name: install
run: make install
- name: check rebuild
id: check_rebuild
working-directory: ./smoke_test/check_rebuild
run: |
nohup air > nohup.out 2> nohup.err < /dev/null &
sleep 15
echo "" >> main.go
sleep 5
cat nohup.out
grep "running" nohup.out | wc -l | if [ "$(cat -)" -eq "2" ]; then echo "::set-output name=value::PASS"; else echo "::set-output name=value::FAIL"; fi
- uses: nick-invision/assert-action@v1
with:
expected: "PASS"
actual: ${{ steps.check_rebuild.outputs.value }}
41 changes: 41 additions & 0 deletions .github/workflows/smoke_test_window_reust_job.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Reusable smoke_test

on:
workflow_call:
inputs:
run_on:
required: true
type: string

jobs:
smoke_test:
name: smoke_test
runs-on: ${{ inputs.run_on }}
steps:
- name: check out code
uses: actions/checkout@v2
- name: setup Go 1.16
id: go
uses: actions/setup-go@v2
with:
go-version: ^1.16
- name: install
run: make install
- name: check rebuild
id: check_rebuild
working-directory: ./smoke_test/check_rebuild
run: |
nohup air > nohup.out &
sleep 15
echo "" >> main.go
sleep 5
cat nohup.out
If ($(grep "running" nohup.out | wc -l) –eq '2' ) {
echo "::set-output name=value::PASS"
} Else {
echo "::set-output name=value::FAIL"
}
- uses: nick-invision/assert-action@v1
with:
expected: "PASS"
actual: ${{ steps.check_rebuild.outputs.value }}

0 comments on commit eb64223

Please sign in to comment.