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
51 changes: 51 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: CI

on:
pull_request:
branches:
- master
- main
push:
branches:
- master
- main

jobs:
test:
name: Test
runs-on: ubuntu-latest
strategy:
matrix:
elixir: ['1.14.2']
otp: ['25.1.1']

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
elixir-version: ${{ matrix.elixir }}
otp-version: ${{ matrix.otp }}

- name: Restore dependencies cache
uses: actions/cache@v3
with:
path: |
deps
_build
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-mix-

- name: Install dependencies
run: mix deps.get

- name: Compile dependencies
run: mix deps.compile

- name: Compile application
run: mix compile --warnings-as-errors

- name: Run tests
run: mix test
38 changes: 38 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Release

on:
push:
branches:
- master
- main

jobs:
release:
name: Release
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'skip ci')"

steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
persist-credentials: false

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18'

- name: Install semantic-release
run: |
npm install -g \
semantic-release@21 \
@semantic-release/git@10 \
@semantic-release/changelog@6 \
@semantic-release/exec@6

- name: Run semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx semantic-release
22 changes: 22 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"branches": ["master", "main"],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
[
"@semantic-release/exec",
{
"prepareCmd": "sed -i 's/version: \"[0-9]\\.[0-9]\\+\\.[0-9]\\+\"/version: \"${nextRelease.version}\"/' mix.exs"
}
],
[
"@semantic-release/git",
{
"assets": ["CHANGELOG.md", "mix.exs"],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}
],
"@semantic-release/github"
]
}
133 changes: 133 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# Contributing to casbin-ex

Thank you for your interest in contributing to casbin-ex! This document provides guidelines and information about the development workflow.

## Development Setup

### Prerequisites

- Elixir 1.14.2 or higher
- Erlang/OTP 25.1.1 or higher

### Getting Started

1. Fork and clone the repository
2. Install dependencies:
```bash
mix deps.get
```
3. Run tests to ensure everything is working:
```bash
mix test
```

## Code Quality

### Formatting

We use the standard Elixir formatter. Before submitting a PR, ensure your code is properly formatted:

```bash
mix format
```

### Testing

All new features and bug fixes should include tests. Run the test suite with:

```bash
mix test
```

## Continuous Integration

### CI Workflow

Every pull request automatically triggers our CI workflow which:

- Sets up Elixir and Erlang environment
- Installs dependencies
- Checks code formatting with `mix format --check-formatted`
- Runs the full test suite with `mix test`

All checks must pass before a PR can be merged.

## Commit Message Convention

We use [Conventional Commits](https://www.conventionalcommits.org/) for automatic versioning and changelog generation.

### Commit Message Format

```
<type>(<scope>): <subject>

<body>

<footer>
```

### Types

- **feat**: A new feature (triggers a minor version bump)
- **fix**: A bug fix (triggers a patch version bump)
- **docs**: Documentation only changes
- **style**: Changes that don't affect the meaning of the code
- **refactor**: A code change that neither fixes a bug nor adds a feature
- **perf**: A code change that improves performance
- **test**: Adding missing tests or correcting existing tests
- **chore**: Changes to the build process or auxiliary tools

### Breaking Changes

To trigger a major version bump, include `BREAKING CHANGE:` in the commit footer or add `!` after the type:

```
feat!: remove deprecated API

BREAKING CHANGE: The old API has been removed in favor of the new one.
```

### Examples

```
feat: add support for keyMatch3 function

fix: correct RBAC domain policy matching

docs: update README with installation instructions

chore: update dependencies
```

## Release Process

Releases are automated using [semantic-release](https://semantic-release.gitbook.io/):

1. When a PR is merged to the `master` or `main` branch, the release workflow is triggered
2. Semantic-release analyzes commit messages since the last release
3. If releasable commits are found:
- A new version is determined based on commit types
- The version in `mix.exs` is updated
- A `CHANGELOG.md` is generated/updated
- A Git tag is created
- A GitHub release is published
- Changes are committed back to the repository

## Pull Request Process

1. Create a feature branch from `master`
2. Make your changes following the guidelines above
3. Ensure all tests pass and code is formatted
4. Write clear, conventional commit messages
5. Open a pull request with a clear description
6. Wait for CI checks to pass
7. Address any review feedback
8. Once approved, a maintainer will merge your PR

## Questions?

If you have questions or need help, feel free to:
- Open an issue for discussion
- Reach out to the maintainers

Thank you for contributing! πŸŽ‰
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# Acx

[![GitHub Actions](https://github.com/casbin/casbin-ex/actions/workflows/ci.yml/badge.svg)](https://github.com/casbin/casbin-ex/actions/workflows/ci.yml)
[![Hex.pm](https://img.shields.io/hexpm/v/acx.svg)](https://hex.pm/packages/acx)
[![Release](https://img.shields.io/github/release/casbin/casbin-ex.svg)](https://github.com/casbin/casbin-ex/releases/latest)
[![Discord](https://img.shields.io/discord/1022748306096537660?logo=discord&label=discord&color=5865F2)](https://discord.gg/S5UjpzGZjN)

Acx is an access control library that can do whatever shit
[Casbin](https://casbin.org/) can and much more...

Expand Down