Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Improvements #165

Merged
merged 1 commit into from
Oct 10, 2024
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
4 changes: 0 additions & 4 deletions .eslintignore

This file was deleted.

55 changes: 0 additions & 55 deletions .eslintrc.json

This file was deleted.

8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@ version: 2
updates:
- package-ecosystem: 'npm'
directory: '/'
labels:
- 'area/ci'
- 'bots'
- 'kind/chore'
schedule:
interval: 'monthly'

- package-ecosystem: 'github-actions'
directory: '/'
labels:
- 'area/ci'
- 'bots'
- 'kind/chore'
schedule:
interval: 'monthly'
77 changes: 23 additions & 54 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,70 +6,29 @@ on:
- main

jobs:
buildtest:
name: Build and Unit Test
build-test-check-and-use:
name: Build, Test, Check and Use
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Checkout
uses: actions/checkout@v4

- name: Set Node.js 20
uses: actions/setup-node@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
node-version: 20.x

- name: Print Node.js and npm version
run: |
node --version
npm --version
- name: Set up pnpm
uses: pnpm/action-setup@v3

- run: |
npm install

- run: |
npm run all

use:
name: Use
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set Node.js 20
- name: Set up Node.js
uses: actions/setup-node@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
node-version: 20.x

- name: Print Node.js and npm version
run: |
node --version
npm --version

- uses: cerbos/cerbos-setup-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
version: 'latest'

- uses: ./

checkdist:
name: Check dist/index.js
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set Node.js 20
uses: actions/setup-node@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
node-version: 20.x
node-version-file: '.node-version'

- name: Install dependencies
run: npm ci --legacy-peer-deps
run: |
pnpm install --frozen-lockfile

- name: Rebuild the dist/ directory
run: npm run build
- name: Run all
run: |
npm run all

- name: Compare the expected and actual dist/ directories
run: |
Expand All @@ -79,3 +38,13 @@ jobs:
exit 1
fi
id: diff

- uses: cerbos/cerbos-setup-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
version: 'latest'

- name: Use action
uses: ./
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.vscode
.idea

# Dependency directory
node_modules

Expand Down
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20.18.0
8 changes: 0 additions & 8 deletions BUILD.md

This file was deleted.

37 changes: 30 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
# Cerbos Compile Action

A GitHub action to validate Cerbos policies using the compiler and run policy tests if there are any.
A GitHub action to validate Cerbos policies using the compiler and run policy tests if there are any.

Cerbos helps you super-charge your authorization implementation by writing context-aware access control policies for your application resources. Find out more about Cerbos using the following resources:

* [Cerbos website](https://cerbos.dev)
* [Cerbos documentation](https://docs.cerbos.dev)
* [Cerbos GitHub repository](https://github.com/cerbos/cerbos)
* [Cerbos Slack community](http://go.cerbos.io/slack)
- [Cerbos website](https://cerbos.dev)
- [Cerbos documentation](https://docs.cerbos.dev)
- [Cerbos GitHub repository](https://github.com/cerbos/cerbos)
- [Cerbos Slack community](http://go.cerbos.io/slack)

## Usage

Use the [cerbos-setup-action](https://github.com/cerbos/cerbos-setup-action) to install Cerbos binaries. Then use this action to validate and test your Cerbos policies. See the [documentation](https://docs.cerbos.dev/cerbos/latest/policies/compile.html) for more information about how to compile policies and author policy tests.

Use the [cerbos-setup-action](https://github.com/cerbos/cerbos-setup-action) to install Cerbos binaries. Then use this action to validate and test your Cerbos policies. See the [documentation](https://docs.cerbos.dev/cerbos/latest/policies/compile.html) for more information about how to compile policies and author policy tests.

```yaml
- uses: actions/checkout@v2
Expand All @@ -25,3 +24,27 @@ Use the [cerbos-setup-action](https://github.com/cerbos/cerbos-setup-action) to
with:
policyDir: policies
```

## Development

### Prerequisites

You'll need to install

- Node.js, matching the version specified in our [.node-version](../.node-version) file

- A version manager that supports this file is recommended, for example [n](https://github.com/tj/n#readme).
Note that [nvm](https://github.com/nvm-sh/nvm) [does not](https://github.com/nvm-sh/nvm/issues/794).

- pnpm, matching the version specified in our [package.json](./package.json) file

- After installing Node.js, you can enable [Corepack](https://nodejs.org/api/corepack.html) to transparently install the correct `pnpm` version:
```console
$ corepack enable
```

### Build

```
pnpm run all
```
5 changes: 0 additions & 5 deletions __tests__/main.test.ts

This file was deleted.

Loading
Loading