Skip to content
Open
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
9 changes: 9 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,12 @@ updates:
- "*"
exclude-patterns:
- "eslint"

- package-ecosystem: "nuget"
directory: "/pkg/csharp/src/OpenFga.Language"
schedule:
interval: "weekly"
groups:
dependencies:
patterns:
- "*"
73 changes: 73 additions & 0 deletions .github/workflows/pkg-csharp-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Test (C#)

on:
workflow_call:

permissions:
contents: read

jobs:
lint:
name: Lint C#
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
fetch-depth: 0

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1

- name: Set up .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: '8.0.x'
cache: true
cache-dependency-path: |
./pkg/csharp/src/OpenFga.Language/OpenFga.Language.csproj
./pkg/csharp/test/OpenFga.Language.Tests/OpenFga.Language.Tests.csproj

- name: Lint C# source
run: make lint-csharp

check-gen:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1

- name: Generate Antlr code and validate up to date
run: |
make antlr-gen-csharp
git diff --text --exit-code ./pkg/csharp/src/OpenFga.Language/gen

test:
name: Test C#
runs-on: ubuntu-latest

strategy:
matrix:
dotnet-version: ["8.0.x", "9.0.x"]

steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
fetch-depth: 0

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1

- name: Set up .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ matrix.dotnet-version }}
cache: true
cache-dependency-path: |
./pkg/csharp/src/OpenFga.Language/OpenFga.Language.csproj
./pkg/csharp/test/OpenFga.Language.Tests/OpenFga.Language.Tests.csproj

- name: Test and Build with .NET
run: make test-csharp
24 changes: 24 additions & 0 deletions .github/workflows/pkg-csharp-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: PR (C#)
permissions:
contents: read

on:
workflow_dispatch:
merge_group:
types: [checks_requested]
push:
branches:
- main
pull_request:
paths:
- "pkg/csharp/**"
- "OpenFGAParser.g4"
- "OpenFGALexer.g4"
- "tests/**"
- ".github/workflows/pkg-csharp-pr.yaml"
- ".github/workflows/pkg-csharp-build.yaml"

jobs:
test:
uses: ./.github/workflows/pkg-csharp-build.yaml
secrets: inherit
92 changes: 92 additions & 0 deletions .github/workflows/pkg-csharp-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: Release (C#)

on:
workflow_dispatch:
push:
tags:
- "pkg/csharp/v*"

jobs:
test:
permissions: {}
uses: ./.github/workflows/pkg-csharp-build.yaml
secrets: inherit

publish-nuget:
runs-on: ubuntu-latest
needs: [test]
permissions:
contents: read
packages: write
defaults:
run:
working-directory: "pkg/csharp"

steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
fetch-depth: 0
path: "."
sparse-checkout: "pkg/csharp"
sparse-checkout-cone-mode: false

- name: Set up .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: '8.0.x'

- name: Build package
run: make build

#- name: Publish to NuGet
# run: dotnet nuget push src/OpenFga.Language/bin/Debug/OpenFga.Language.*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json

publish-github-packages:
runs-on: ubuntu-latest
needs: [test]
permissions:
contents: read
packages: write
defaults:
run:
working-directory: "pkg/csharp"

steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
fetch-depth: 0
path: "."
sparse-checkout: "pkg/csharp"
sparse-checkout-cone-mode: false

- name: Set up .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: '8.0.x'

- name: Build package
run: make build

#- name: Publish to GitHub Packages
# run: dotnet nuget push src/OpenFga.Language/bin/Debug/OpenFga.Language.*.nupkg --api-key ${{ secrets.GITHUB_TOKEN }} --source https://nuget.pkg.github.com/openfga/index.json

create-release:
runs-on: ubuntu-latest
needs: [publish-nuget, publish-github-packages]
permissions:
contents: write
packages: write # publish a new github release
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
fetch-depth: 0

- name: Create Release
uses: Roang-zero1/github-create-release-action@57eb9bdce7a964e48788b9e78b5ac766cb684803 # v3.0.1
with:
version_regex: ^pkg/csharp/v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+
prerelease_regex: ^pkg/csharp/v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+-(alpha|beta)\.[[:digit:]]+$
changelog_file: pkg/csharp/CHANGELOG.md
create_draft: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46 changes: 42 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,54 @@ ANTLR_CMD=${docker_binary} run -t --rm -v ${PWD}:/app:Z ${ANTLR_DOCKER_IMAGE}
all: build

.PHONY: antlr-gen
antlr-gen: antlr-gen-go antlr-gen-js antlr-gen-java
antlr-gen: antlr-gen-go antlr-gen-js antlr-gen-java antlr-gen-csharp

.PHONY: build
build: build-go build-js build-java
build: build-go build-js build-java build-csharp

.PHONY: test
test: test-go test-js test-java
test: test-go test-js test-java test-csharp

.PHONY: lint
lint: lint-go lint-js lint-java lint-tests
lint: lint-go lint-js lint-java lint-csharp lint-tests

#### C# #####

.PHONY: antlr-gen-csharp
antlr-gen-csharp:
$(MAKE) antlr-gen-base language=CSharp packageName=csharp/src/OpenFga.Language

.PHONY: build-csharp
build-csharp: antlr-gen-csharp
$(MAKE) -C pkg/csharp build

.PHONY: run-csharp
run-csharp: antlr-gen-csharp
$(MAKE) -C pkg/csharp run

.PHONY: clean-csharp
clean-csharp:
$(MAKE) -C pkg/csharp clean

.PHONY: test-csharp
test-csharp: antlr-gen-csharp
$(MAKE) -C pkg/csharp test

.PHONY: lint-csharp
lint-csharp: antlr-gen-csharp
$(MAKE) -C pkg/csharp lint

.PHONY: audit-csharp
audit-csharp: antlr-gen-csharp
$(MAKE) -C pkg/csharp audit

.PHONY: format-csharp
format-csharp: antlr-gen-csharp
$(MAKE) -C pkg/csharp format

.PHONY: all-tests-csharp
all-tests-csharp: antlr-gen-csharp
$(MAKE) -C pkg/csharp all-tests

#### Go #####

Expand Down
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,26 +44,27 @@ OpenFGA is designed to make it easy for application builders to model their perm
| JS | [![@openfga/syntax-transformer on npm](https://img.shields.io/npm/v/%40openfga%2Fsyntax-transformer/beta?label=%40openfga%2Fsyntax-transformer&style=flat-square)](https://www.npmjs.com/package/@openfga/syntax-transformer) | [README](/pkg/js/README.md) |
| Go | [![GitHub Release](https://img.shields.io/github/v/release/openfga/language?include_prereleases&filter=pkg%2Fgo%2Fv*&label=openfga-language)](https://github.com/openfga/language/tree/main/pkg/go) | [README](/pkg/go/README.md) |
| Java | [![openfga-language on Maven Central](https://img.shields.io/maven-central/v/dev.openfga/openfga-language?style=flat-square&label=openfga-language)](https://central.sonatype.com/artifact/dev.openfga/openfga-language) | [README](/pkg/java/README.md) |
| C# | [![openfga-language on NuGet](https://img.shields.io/nuget/v/openfga-language?style=flat-square&label=openfga-language)](https://www.nuget.org/packages/openfga-language) | [README](/pkg/csharp/README.md) |

## About This Repo

This repo contains everything needed to interact with the OpenFGA Authorization Models schema versions 1.1+, in multiple languages (currently, Go and JS are supported).
This repo contains everything needed to interact with the OpenFGA Authorization Models schema versions 1.1+, in multiple languages (currently, Go, JS, Java, and C# are supported).

| Feature | Implemented in ANTLR |
| ---------- | ------------------------------------------------------------------------ |
| Basic DSL | ✅ |
| Nesting | ✅ (partial, see [#113](https://github.com/openfga/language/issues/113)) |
| Conditions | ✅ |

| Feature | Go | JS | Java |
| ----------------------------------------------------- | ---------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | ------------ |
| Transformer from the DSL to JSON and from JSON to DSL | ✅ | ✅ | ✅ |
| Syntactic Model Validations | ✅ | ✅ | ✅ |
| Schema 1.0 | ❌ | ❌ (supported in [v0.1.6](https://www.npmjs.com/package/@openfga/syntax-transformer/v/0.1.6) and below) | ❌ |
| Schema 1.1 | ✅ | ✅ (supported in [v0.2.0](https://www.npmjs.com/package/@openfga/syntax-transformer) and above) | ✅ |
| Schema 1.2 (Modular Models) | ✅ | ✅ | ✅ |
| Semantic Model Validations | ❌ (planned, see [#99](https://github.com/openfga/language/issues/99)) | ✅ | ✅ |
| Graphing & Utility Methods | ❌ (planned) | ❌ (planned) | ❌ (planned) |
| Feature | Go | JS | Java | C# |
| ----------------------------------------------------- | ---------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | ------------ | ------------ |
| Transformer from the DSL to JSON and from JSON to DSL | ✅ | ✅ | ✅ | ✅ |
| Syntactic Model Validations | ✅ | ✅ | ✅ | ✅ |
| Schema 1.0 | ❌ | ❌ (supported in [v0.1.6](https://www.npmjs.com/package/@openfga/syntax-transformer/v/0.1.6) and below) | ❌ | ❌ |
| Schema 1.1 | ✅ | ✅ (supported in [v0.2.0](https://www.npmjs.com/package/@openfga/syntax-transformer) and above) | ✅ | ✅ |
| Schema 1.2 (Modular Models) | ✅ | ✅ | ✅ | ✅ |
| Semantic Model Validations | ❌ (planned, see [#99](https://github.com/openfga/language/issues/99)) | ✅ | ✅ | ✅ |
| Graphing & Utility Methods | ❌ (planned) | ❌ (planned) | ❌ (planned) | ❌ (planned) |

## CLI

Expand Down
Loading