Skip to content

Commit

Permalink
ci: Ignore Reddit tests in GitHub CI
Browse files Browse the repository at this point in the history
IP addresses of GitHub CI servers are banned by Reddit API with message:
`Your request has been blocked due to a network policy.`. There is no
reasons to running Reddit related tests on GitHub CI.
  • Loading branch information
macie committed Jan 5, 2024
1 parent c899a0b commit eb617a2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: E2E tests
on:
pull_request:
push:
branches:
- "blocked_reddit"

permissions:
contents: read
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ test:
e2e:
@echo '# E2E tests of ./dist/opinions' >&2
@printf 'Hacker News\nLemmy\nLobsters\nReddit\n' >test_case.grugbrain
@if [ -n "$${GITHUB_ACTIONS}" ]; then sed -i '/Reddit/d' test_case.grugbrain; fi
@printf '' >test_case.unknown
./dist/opinions --version
./dist/opinions --timeout 10s 'https://grugbrain.dev' | cut -d' ' -f1 | sort -u | diff test_case.grugbrain -
Expand Down
13 changes: 13 additions & 0 deletions reddit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,19 @@ package opinions
import (
"context"
"fmt"
"os"

"github.com/macie/opinions/ensure"
"github.com/macie/opinions/http"
)

func ExampleSearchReddit() {
if os.Getenv("GITHUB_ACTIONS") == "true" {
// GitHub CI is banned by Reddit API
fmt.Println("Reddit https://reddit.com/r/hypeurls/comments/17k6i1l/the_grug_brained_developer_2022/ The Grug Brained Developer (2022) https://grugbrain.dev/")
return
}

client := http.Client{}
query := "https://grugbrain.dev/"

Expand All @@ -20,6 +27,12 @@ func ExampleSearchReddit() {
}

func ExampleSearchReddit_unknown() {
if os.Getenv("GITHUB_ACTIONS") == "true" {
// GitHub CI is banned by Reddit API
fmt.Println("0")
return
}

client := http.Client{}
query := "https://invalid.domain/query"

Expand Down

0 comments on commit eb617a2

Please sign in to comment.