Add e2e test config #203
This file contains hidden or 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
| # 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: [ '*' ] | |
| pull_request: | |
| branches: [ '*' ] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Get branch name | |
| id: branch-name-build | |
| run: | | |
| if [ "$GITHUB_EVENT_NAME" == "pull_request" ]; then | |
| echo "::set-output name=branch::$GITHUB_HEAD_REF" | |
| else | |
| echo "::set-output name=branch::${GITHUB_REF#refs/heads/}" | |
| fi | |
| - name: Set up Go | |
| uses: actions/setup-go@v4 | |
| with: | |
| go-version-file: 'go.mod' | |
| - name: Use go get with current branch if not master | |
| run: | | |
| BRANCH_NAME="${{ steps.branch-name-build.outputs.branch }}" | |
| if [ "$BRANCH_NAME" != "master" ]; then | |
| go get github.com/fumiya-kume/mdefaults@$BRANCH_NAME | |
| fi | |
| - name: Cache Go modules | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| ~/.cache/go-build | |
| ~/go/pkg/mod | |
| key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
| - name: Build | |
| run: go build -v ./... | |
| test: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Get branch name | |
| id: branch-name-test | |
| run: | | |
| if [ "$GITHUB_EVENT_NAME" == "pull_request" ]; then | |
| echo "::set-output name=branch::$GITHUB_HEAD_REF" | |
| else | |
| echo "::set-output name=branch::${GITHUB_REF#refs/heads/}" | |
| fi | |
| - name: Set up Go | |
| uses: actions/setup-go@v4 | |
| with: | |
| go-version-file: 'go.mod' | |
| - name: Use go get with current branch if not master | |
| run: | | |
| BRANCH_NAME="${{ steps.branch-name-test.outputs.branch }}" | |
| if [ "$BRANCH_NAME" != "master" ]; then | |
| go get github.com/fumiya-kume/mdefaults@$BRANCH_NAME | |
| fi | |
| - name: Test | |
| run: go test -v ./... | |
| lint: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Get branch name | |
| id: branch-name-lint | |
| run: | | |
| if [ "$GITHUB_EVENT_NAME" == "pull_request" ]; then | |
| echo "::set-output name=branch::$GITHUB_HEAD_REF" | |
| else | |
| echo "::set-output name=branch::${GITHUB_REF#refs/heads/}" | |
| fi | |
| - name: Set up Go | |
| uses: actions/setup-go@v4 | |
| with: | |
| go-version-file: 'go.mod' | |
| - name: Use go get with current branch if not master | |
| run: | | |
| BRANCH_NAME="${{ steps.branch-name-lint.outputs.branch }}" | |
| if [ "$BRANCH_NAME" != "master" ]; then | |
| go get github.com/fumiya-kume/mdefaults@$BRANCH_NAME | |
| fi | |
| - name: Install golangci-lint | |
| run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest | |
| - name: Run golangci-lint | |
| run: golangci-lint run |