Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 3 additions & 51 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.26'
go-version: '1.23'

- name: Download dependencies
run: go mod download
Expand All @@ -38,7 +38,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.26'
go-version: '1.23'

- name: golangci-lint
uses: golangci/golangci-lint-action@v5
Expand All @@ -53,7 +53,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.26'
go-version: '1.23'

- name: Build binaries
run: |
Expand All @@ -68,51 +68,3 @@ jobs:
name: binaries
path: bin/

docker:
runs-on: ubuntu-latest
needs: [test, lint, build]
steps:
- uses: actions/checkout@v7

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4

- name: Build Docker image
uses: docker/build-push-action@v7
with:
context: .
push: false
tags: jolly3/github-pr-concourse-resource:latest
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Test Docker image
run: |
docker run --rm jolly3/github-pr-concourse-resource:latest /opt/resource/check --version || true
docker run --rm jolly3/github-pr-concourse-resource:latest /opt/resource/in --version || true
docker run --rm jolly3/github-pr-concourse-resource:latest /opt/resource/out --version || true

e2e:
runs-on: ubuntu-latest
# Only run e2e tests when token is available (not on forks)
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
steps:
- uses: actions/checkout@v7

- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.26'

- name: Download dependencies
run: go mod download

- name: Run E2E tests
env:
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TEST_REPOSITORY: ujala-singh/github-repository-dispatch-receiver
run: |
echo "Running E2E tests with automatic GitHub token..."
echo "Testing against repository: $TEST_REPOSITORY"
go test -v -tags=e2e ./e2e/...

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ cmd/in/in
cmd/out/out
dist/
build/
.task/
bin/

# OS specific
.DS_Store
Expand Down
2 changes: 2 additions & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
golang 1.23.6
task 3.49.1
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.26-alpine AS builder
FROM golang:1.23-alpine AS builder

RUN apk add --no-cache git openssh-client ca-certificates

Expand Down
65 changes: 30 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,41 @@ resources:

## Source Configuration

### Authentication

You can authenticate with either a **personal access token** or **GitHub App credentials** (recommended).

#### Personal Access Token

```yaml
source:
repository: owner/repo
access_token: ((github-token))
```

#### GitHub App (Recommended)

```yaml
source:
repository: owner/repo
github_app_id: ((github-app-id))
github_app_installation_id: ((github-app-installation-id))
github_app_private_key: ((github-app-private-key))
```

See [docs/GITHUB_APP_AUTHENTICATION.md](docs/GITHUB_APP_AUTHENTICATION.md) for detailed setup instructions.

### Common Configuration (Both Modes)

| Parameter | Required | Default | Description |
|-----------|----------|---------|-------------|
| `repository` | Yes | - | Repository in `owner/repo` format |
| `access_token` | Yes | - | GitHub personal access token with `repo` scope |
| `access_token` | No* | - | GitHub personal access token with `repo` scope |
| `github_app_id` | No* | - | GitHub App ID |
| `github_app_installation_id` | No* | - | GitHub App Installation ID |
| `github_app_private_key` | No* | - | GitHub App private key (PEM format) |

*Note: Either `access_token` OR all three GitHub App parameters (`github_app_id`, `github_app_installation_id`, `github_app_private_key`) must be provided.
| `v3_endpoint` | No | `https://api.github.com` | GitHub API v3 endpoint (for GitHub Enterprise) |
| `v4_endpoint` | No | `https://api.github.com/graphql` | GitHub API v4 endpoint (for GitHub Enterprise) |
| `hosting_endpoint` | No | `https://github.com` | GitHub hosting endpoint (for GitHub Enterprise) |
Expand Down Expand Up @@ -344,42 +373,8 @@ go test -cover ./...

# Run with coverage report
task test-coverage

# Run e2e tests (requires GITHUB_ACCESS_TOKEN)
export GITHUB_ACCESS_TOKEN=your_token_here
task test-e2e

# Run all tests including e2e
task test-all
```

#### E2E Tests

End-to-end tests verify functionality against real GitHub repositories. See [e2e/README.md](e2e/README.md) for detailed setup instructions.

**Quick start:**
```bash
# Set up token
export GITHUB_ACCESS_TOKEN="your_github_token"

# Optional: specify test repository
export TEST_REPOSITORY="owner/repo"

# Run e2e tests
go test -v -tags=e2e ./e2e/...
```

**What's tested:**
- ✅ Check operation (both PR and PR list modes)
- ✅ In operation (merge, rebase, checkout strategies)
- ✅ Out operation (status updates, comments)
- ✅ Path filtering (include/exclude patterns)
- ✅ API cost optimization
- ✅ Metadata file generation

**CI Integration:**
E2E tests run automatically in CI using GitHub's automatic `GITHUB_TOKEN` (no setup required).

## Differences from Other Resources

### vs. `github-pr-resource` (telia-oss)
Expand Down
34 changes: 3 additions & 31 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,35 +32,7 @@ tasks:
cmds:
- go test -coverprofile=coverage.out ./...
- go tool cover -html=coverage.out -o coverage.html
- echo "Coverage report generated: coverage.html"

test-e2e:
desc: "Run e2e tests (requires GITHUB_ACCESS_TOKEN)"
cmds:
- |
if [ -z "$GITHUB_ACCESS_TOKEN" ]; then
echo "❌ GITHUB_ACCESS_TOKEN environment variable is required"
echo " export GITHUB_ACCESS_TOKEN=your_token_here"
exit 1
fi
- go test -v -tags=e2e ./e2e/...

test-e2e-verbose:
desc: "Run e2e tests with verbose output"
cmds:
- |
if [ -z "$GITHUB_ACCESS_TOKEN" ]; then
echo "❌ GITHUB_ACCESS_TOKEN environment variable is required"
echo " export GITHUB_ACCESS_TOKEN=your_token_here"
exit 1
fi
- go test -v -tags=e2e ./e2e/... -v

test-all:
desc: "Run all tests including e2e"
cmds:
- task: test
- task: test-e2e
- 'echo "Coverage report generated: coverage.html"'

lint:
desc: "Run linters"
Expand Down Expand Up @@ -95,7 +67,7 @@ tasks:
REGISTRY: '{{.REGISTRY | default "jolly3"}}'
cmds:
- docker run --rm {{.REGISTRY}}/github-pr-concourse-resource:latest /opt/resource/check --help || true
- echo "Docker image built successfully"
- 'echo "Docker image built successfully"'

docker-push:
desc: "Push Docker image to registry"
Expand All @@ -105,7 +77,7 @@ tasks:
cmds:
- docker push {{.REGISTRY}}/github-pr-concourse-resource:latest
- docker push {{.REGISTRY}}/github-pr-concourse-resource:{{.VERSION}}
- echo "✅ Successfully pushed to {{.REGISTRY}}"
- 'echo "✅ Successfully pushed to {{.REGISTRY}}"'

clean:
desc: "Clean build artifacts"
Expand Down
Loading
Loading