diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..635c02b --- /dev/null +++ b/.github/workflows/ci.yml @@ -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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..c11b137 --- /dev/null +++ b/.github/workflows/release.yml @@ -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 diff --git a/.releaserc.json b/.releaserc.json new file mode 100644 index 0000000..d181aff --- /dev/null +++ b/.releaserc.json @@ -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" + ] +} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..9f16f77 --- /dev/null +++ b/CONTRIBUTING.md @@ -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 + +``` +(): + + + +