feat: configurable external fga server #12
Workflow file for this run
This file contains 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
name: Test Action | |
on: | |
workflow_dispatch: | |
pull_request: | |
types: | |
- opened | |
- edited | |
- synchronize | |
jobs: | |
test: | |
name: Run test | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: default values | |
uses: ./ | |
- name: specify folder | |
uses: ./ | |
with: | |
test_path: ./example | |
- name: single file | |
uses: ./ | |
with: | |
test_path: ./example/model.fga.yaml | |
test_conditions_support: | |
name: Test conditions support | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
test: | |
- openfga_tag: v1.5.3 | |
conditions_supported: true | |
- openfga_tag: v1.4.3 | |
conditions_supported: true | |
- openfga_tag: v1.3.7 | |
conditions_supported: false | |
services: | |
postgres: | |
image: postgres:14 | |
env: | |
POSTGRES_USER: openfga | |
POSTGRES_PASSWORD: "1234" | |
ports: | |
- 5432:5432 | |
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | |
env: | |
OPENFGA_DATASTORE_ENGINE: 'postgres' | |
OPENFGA_DATASTORE_URI: 'postgres://openfga:[email protected]:5432/openfga' | |
OPENFGA_LOG_LEVEL: debug | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install OpenFGA server ${{ matrix.test.openfga_tag }} | |
uses: jaxxstorm/[email protected] | |
with: | |
repo: openfga/openfga | |
tag: ${{ matrix.test.openfga_tag }} | |
cache: enable | |
- name: Migrate OpenFGA Database | |
shell: bash | |
run: openfga migrate | |
- name: Start OpenFGA Server | |
shell: bash | |
run: openfga run & | |
- name: Install OpenFGA cli | |
uses: jaxxstorm/[email protected] | |
with: | |
repo: openfga/cli | |
cache: enable | |
- name: Install jq | |
uses: dcarbone/install-jq-action@v2 | |
- name: Create store with model | |
id: 'store' | |
run: | | |
fga store create --model ./example/model_with_conditions.fga > store_response.json | |
cat store_response.json | |
store_id=$(jq -r '.store.id' store_response.json) | |
echo "store_id=${store_id}" >> $GITHUB_OUTPUT | |
- name: Run OpenFGA CLI Tests | |
id: 'tests' | |
uses: ./ | |
continue-on-error: true | |
with: | |
test_path: ./example/model_with_conditions.fga.yaml | |
fga_server_url: 'http://localhost:8080' | |
fga_server_store_id: ${{ steps.store.outputs.store_id }} | |
- name: Assert expected results | |
run: | | |
if [ "${{ matrix.test.conditions_supported }}" == "true" ] && [ "${{ steps.tests.outcome }}" == "failure" ] | |
then | |
echo "${{ matrix.test.openfga_tag }} is expected to support conditions but tests failed" | |
exit 1 | |
fi | |
if [ "${{ matrix.test.conditions_supported }}" == "false" ] && [ "${{ steps.tests.outcome }}" == "success" ] | |
then | |
echo "${{ matrix.test.openfga_tag }} is expected to not support conditions but tests passed" | |
exit 1 | |
fi | |