Skip to content
Merged
Show file tree
Hide file tree
Changes from 19 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
98 changes: 98 additions & 0 deletions .github/workflows/acceptance-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: Acceptance Tests

on:
push:
branches: [main]
workflow_dispatch:
inputs:
run_all:
description: 'Run all tests'
required: false
default: true
type: boolean
enable_keto_tests:
description: 'Keto/relationship tests'
required: false
default: false
type: boolean
enable_b2b_tests:
description: 'B2B/organization tests'
required: false
default: false
type: boolean
enable_social_provider_tests:
description: 'Social provider tests'
required: false
default: false
type: boolean
enable_schema_tests:
description: 'Identity schema tests'
required: false
default: false
type: boolean
enable_project_tests:
description: 'Project create/delete tests'
required: false
default: false
type: boolean

permissions:
contents: read
pull-requests: read

jobs:
detect-changes:
name: Detect Changes
runs-on: ubuntu-latest
outputs:
source-changed: ${{ steps.filter.outputs.source }}
steps:
- name: Checkout
uses: actions/checkout@v4

- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
source:
- '**.go'
- 'go.mod'
- 'go.sum'
- '.github/workflows/acceptance-test.yml'

acceptance-test:
name: Build & Acceptance Test
needs: detect-changes
if: ${{ needs.detect-changes.outputs.source-changed == 'true' || github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-latest
timeout-minutes: 30

env:
ORY_WORKSPACE_API_KEY: ${{ secrets.ORY_WORKSPACE_API_KEY }}
ORY_WORKSPACE_ID: ${{ secrets.ORY_WORKSPACE_ID }}
ORY_CONSOLE_API_URL: ${{ secrets.ORY_CONSOLE_API_URL }}
ORY_PROJECT_API_URL: ${{ secrets.ORY_PROJECT_API_URL }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: true

- name: Install dependencies
run: make deps-ci

- name: Run Acceptance Tests
env:
# For push to main: run all tests
# For manual dispatch: run_all=true runs all, otherwise use individual toggles
ORY_KETO_TESTS_ENABLED: ${{ github.event_name == 'push' || github.event.inputs.run_all == 'true' || github.event.inputs.enable_keto_tests == 'true' }}
ORY_B2B_ENABLED: ${{ github.event_name == 'push' || github.event.inputs.run_all == 'true' || github.event.inputs.enable_b2b_tests == 'true' }}
ORY_SOCIAL_PROVIDER_TESTS_ENABLED: ${{ github.event_name == 'push' || github.event.inputs.run_all == 'true' || github.event.inputs.enable_social_provider_tests == 'true' }}
ORY_SCHEMA_TESTS_ENABLED: ${{ github.event_name == 'push' || github.event.inputs.run_all == 'true' || github.event.inputs.enable_schema_tests == 'true' }}
ORY_PROJECT_TESTS_ENABLED: ${{ github.event_name == 'push' || github.event.inputs.run_all == 'true' || github.event.inputs.enable_project_tests == 'true' }}
run: ./scripts/run-acceptance-tests.sh -v -timeout 20m ./...
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ permissions:

jobs:
goreleaser:
runs-on: ubuntu-latest
runs-on: ubuntu-slim
steps:
- uses: actions/checkout@v4
with:
Expand Down
83 changes: 0 additions & 83 deletions .github/workflows/test.yml

This file was deleted.

50 changes: 50 additions & 0 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Unit Tests

on:
push:
branches: [main]
pull_request:
branches: [main]

permissions:
contents: read
pull-requests: read

jobs:
detect-changes:
name: Detect Changes
runs-on: ubuntu-latest
outputs:
source-changed: ${{ steps.filter.outputs.source }}
steps:
- name: Checkout
uses: actions/checkout@v4

- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
source:
- '**.go'
- 'go.mod'
- 'go.sum'
- '.github/workflows/unit-test.yml'

unit-test:
name: Build & Unit Test
needs: detect-changes
if: ${{ needs.detect-changes.outputs.source-changed == 'true' }}
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: true

- name: Run Unit Tests
run: go test -short -v -cover ./...
29 changes: 25 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,37 @@ make install

### Running Tests

Acceptance tests are **self-contained** - they automatically create a temporary Ory project, run tests against it, and clean up when done.

```bash
# Unit tests (no credentials needed)
make test

# Acceptance tests (requires Ory credentials)
export ORY_WORKSPACE_API_KEY="ory_wak_..."
export ORY_PROJECT_API_KEY="ory_pat_..."
export ORY_PROJECT_ID="..."
export ORY_PROJECT_SLUG="..."
make testacc
export ORY_WORKSPACE_ID="..."
make test-acc

# Acceptance tests with debug logging
make test-acc-verbose

# Run all tests with all features enabled
make test-acc-all
```

#### Optional Feature Flags

Some tests require specific Ory plan features. Enable them with environment variables:

```bash
# Run relationship/Keto tests
ORY_KETO_TESTS_ENABLED=true make test-acc

# Run B2B/organization tests (requires B2B plan)
ORY_B2B_ENABLED=true make test-acc

# Run social provider tests
ORY_SOCIAL_PROVIDER_TESTS_ENABLED=true make test-acc
```

### Using Local Provider
Expand Down
Loading