-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
860c5e9
commit 1fc0a56
Showing
3 changed files
with
99 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,30 @@ | ||
name: GitHub Actions Demo | ||
run-name: ${{ github.actor }} is testing out GitHub Actions 🚀 | ||
on: [push] | ||
# This workflow will build a golang project | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go | ||
|
||
name: Go | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
Explore-GitHub-Actions: | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." | ||
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!" | ||
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." | ||
- name: Check out repository code | ||
uses: actions/checkout@v4 | ||
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner." | ||
- run: echo "🖥️ The workflow is now ready to test your code on the runner." | ||
- name: List files in the repository | ||
run: | | ||
ls ${{ github.workspace }} | ||
- run: echo "🍏 This job's status is ${{ job.status }}." | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.18' | ||
|
||
# -v : パッケージ名を出力 | ||
- name: Build | ||
run: go build -v ./... | ||
|
||
# -v : テスト成功しても値を出力 | ||
- name: Test | ||
run: go test -v ./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package test_ci | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
func funReturnMes() string { | ||
message := "起動確認" | ||
fmt.Print(message) | ||
return message | ||
} | ||
|
||
func funcRetunTwoTimes(i int) int { | ||
fmt.Printf("x:%v", i) | ||
return i * 2 | ||
} | ||
|
||
func Parent() { | ||
mes := funReturnMes() | ||
x := 1 | ||
twoTimesInt := funcRetunTwoTimes(x) | ||
fmt.Println("result", mes, twoTimesInt) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package test_ci | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func Test_funReturnMes(t *testing.T) { | ||
tests := map[string]struct { | ||
want string | ||
expectErr bool | ||
}{ | ||
"成功": {want: "起動確認", expectErr: false}, | ||
} | ||
for name, tt := range tests { | ||
t.Run(name, func(t *testing.T) { | ||
if got := funReturnMes(); got != tt.want { | ||
t.Errorf("funReturnMes() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} | ||
|
||
func Test_funcRetunTwoTimes(t *testing.T) { | ||
cases := map[string]struct { | ||
i int | ||
want int | ||
expectErr bool | ||
}{ | ||
"成功": {1, 2, false}, | ||
"失敗": {1, 1, true}, | ||
} | ||
for testName, tt := range cases { | ||
t.Run(testName, func(t *testing.T) { | ||
if tt.expectErr == true { | ||
if got := funcRetunTwoTimes(tt.i); got == tt.want { | ||
t.Errorf("funcRetunTwoTimes() = %v, want %v", got, tt.want) | ||
} | ||
} else { | ||
if got := funcRetunTwoTimes(tt.i); got != tt.want { | ||
t.Errorf("funcRetunTwoTimes() = %v, not want %v", got, tt.want) | ||
} | ||
} | ||
}) | ||
} | ||
} | ||
|
||
////////////////////////////////////// | ||
// これをciで実行する | ||
//////////////////////////////// |