Skip to content

Commit

Permalink
Merge pull request #27 from gopherguides/workflow-fix
Browse files Browse the repository at this point in the history
fix tests from looking at docs directory
  • Loading branch information
corylanou authored Sep 10, 2024
2 parents e59c275 + b1c8bf3 commit 179f89f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 15 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/hype.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,19 @@ You need to give permission to your GitHub Actions to create a pull request in y

Under `Workflow Permissions`

- Check `Allow GitHub Actions to create and approve pull requests`.
- Check `Read and write permissions`
- Check `Allow GitHub Actions to create and approve pull requests`.
- Check `Read and write permissions`

### Personal Access Token

Alternately, you can use tokens to give permission to your action.

It is recommend to use a GitHub [Personnal Acces Token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token#creating-a-fine-grained-personal-access-token) like: `${{ `{{secrets.PAT}}` }}` instead of using `{{ `${{secrets.GITHUB_TOKEN}}` }}` in GitHub Actions.
It is recommend to use a GitHub [Personnal Acces Token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token#creating-a-fine-grained-personal-access-token) like: `${{`{{secrets.PAT}}`}}` instead of using `{{`${{secrets.GITHUB_TOKEN}}`}}` in GitHub Actions.

## The Action

The current action is set to only generate the readme on a pull request and commit it back to that same pull request. You can modify this to your own needs.

It should be noted that we are ignoring the `docs` directory in our workflow because we purposefully have broken code examples. You should not do this. Your can simply run `go test ./...` and `staticcheck ./...` respectively in your actions.

<code src="hype.yml"></code>
2 changes: 1 addition & 1 deletion .github/workflows/hype.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.22.x"
go-version: "1.23.x"
cache-dependency-path: subdir/go.sum
- name: Install hype
run: go install github.com/gopherguides/hype/cmd/hype@latest
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,27 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [1.22.x]
go-version: [1.23.x]
os: [macos-latest, ubuntu-latest]
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.22.x"
go-version: "1.23.x"
- name: Go Environment
run: go env
- name: Verify Go Modules
run: go mod verify
- name: Build
run: go build -v ./cmd/hype/
- name: Run tests with Race Detector
run: go test -race -vet=off ./...
run: |
go_dirs=$(go list ./... | grep -v '/docs')
go test -race -vet=off $go_dirs
- name: Install staticcheck
run: go install honnef.co/go/tools/cmd/staticcheck@latest
- name: Run staticcheck
run: staticcheck ./...
run: |
go_dirs=$(go list ./... | grep -v '/docs')
staticcheck $go_dirs
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ $ go run .
Hello World

--------------------------------------------------------------------------------
Go Version: go1.22.6
Go Version: go1.23.1

```

Expand Down Expand Up @@ -160,7 +160,7 @@ $ go run .
Hello World

--------------------------------------------------------------------------------
Go Version: go1.22.6
Go Version: go1.23.1

```

Expand Down Expand Up @@ -189,7 +189,7 @@ $ go run .
Hello World

--------------------------------------------------------------------------------
Go Version: go1.22.6
Go Version: go1.23.1

```

Expand Down Expand Up @@ -219,7 +219,7 @@ $ go run .
./main.go:7:6: undefined: fmt.Prin

--------------------------------------------------------------------------------
Go Version: go1.22.6
Go Version: go1.23.1

```

Expand Down Expand Up @@ -256,7 +256,7 @@ type Context interface{ ... }
func WithoutCancel(parent Context) Context

--------------------------------------------------------------------------------
Go Version: go1.22.6
Go Version: go1.23.1

```
Expand All @@ -279,7 +279,7 @@ func WithCancel(parent Context) (ctx Context, cancel CancelFunc)
call cancel as soon as the operations running in this Context complete.

--------------------------------------------------------------------------------
Go Version: go1.22.6
Go Version: go1.23.1

```
Expand Down Expand Up @@ -1269,6 +1269,8 @@ It is recommend to use a GitHub [Personnal Acces Token](https://docs.github.com/
The current action is set to only generate the readme on a pull request and commit it back to that same pull request. You can modify this to your own needs.
It should be noted that we are ignoring the `docs` directory in our workflow because we purposefully have broken code examples. You should not do this. Your can simply run `go test ./...` and `staticcheck ./...` respectively in your actions.
```yml
name: Generate README with Hype
on: [pull_request]
Expand All @@ -1283,7 +1285,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.22.x"
go-version: "1.23.x"
cache-dependency-path: subdir/go.sum
- name: Install hype
run: go install github.com/gopherguides/hype/cmd/hype@latest
Expand Down

0 comments on commit 179f89f

Please sign in to comment.