Skip to content

Commit 8669523

Browse files
feat: Setup GitHub Actions CI and semantic release (#4)
1 parent 438db1c commit 8669523

24 files changed

+893
-0
lines changed

.github/workflows/maven-ci.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: build
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
services:
9+
mysql:
10+
image: mysql
11+
env:
12+
MYSQL_ROOT_PASSWORD: casbin_test
13+
MYSQL_DATABASE: casbin
14+
MYSQL_USER: casbin_test
15+
MYSQL_PASSWORD: TEST_casbin
16+
ports:
17+
- 3306:3306
18+
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
19+
postgres:
20+
image: postgres
21+
env:
22+
POSTGRES_DB: casbin
23+
POSTGRES_USER: casbin_test
24+
POSTGRES_PASSWORD: TEST_casbin
25+
ports:
26+
- 5432:5432
27+
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
28+
sqlserver:
29+
image: mcr.microsoft.com/mssql/server:2019-latest
30+
env:
31+
SA_PASSWORD: 9G3iqmzQDw9zCXII
32+
ACCEPT_EULA: Y
33+
ports:
34+
- 1433:1433
35+
36+
steps:
37+
- name: Checkout
38+
uses: actions/checkout@v2
39+
with:
40+
fetch-depth: '0'
41+
42+
- name: Install mssql-tools
43+
run: |
44+
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
45+
curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list
46+
sudo apt-get update
47+
sudo apt-get install mssql-tools unixodbc-dev
48+
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
49+
- name: Create database for sqlserver
50+
run: sqlcmd -S 127.0.0.1,1433 -U sa -P '9G3iqmzQDw9zCXII' -Q "CREATE DATABASE casbin"
51+
52+
- name: Set up JDK 1.8
53+
uses: actions/setup-java@v1
54+
with:
55+
java-version: 1.8
56+
server-id: ossrh
57+
server-username: OSSRH_JIRA_USERNAME
58+
server-password: OSSRH_JIRA_PASSWORD
59+
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
60+
gpg-passphrase: GPG_PASSPHRASE
61+
62+
- name: Build with Maven
63+
run: mvn clean test cobertura:cobertura
64+
65+
- name: Codecov
66+
uses: codecov/codecov-action@v1
67+
with:
68+
token: ${{ secrets.CODECOV_TOKEN }}
69+
70+
- name: Set up Node.js
71+
uses: actions/setup-node@v2
72+
with:
73+
node-version: 16
74+
75+
- name: Sematic Release
76+
run: |
77+
npm install -g @conveyal/maven-semantic-release semantic-release
78+
semantic-release --prepare @conveyal/maven-semantic-release --publish @semantic-release/github,@conveyal/maven-semantic-release --verify-conditions @semantic-release/github,@conveyal/maven-semantic-release --verify-release @conveyal/maven-semantic-release
79+
env:
80+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
81+
GPG_KEY_NAME: ${{ secrets.GPG_KEY_NAME }}
82+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
83+
OSSRH_JIRA_USERNAME: ${{ secrets.OSSRH_JIRA_USERNAME }}
84+
OSSRH_JIRA_PASSWORD: ${{ secrets.OSSRH_JIRA_PASSWORD }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*.zip
1919
*.tar.gz
2020
*.rar
21+
*.iml
2122

2223
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
2324
hs_err_pid*

examples/rbac_model.conf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[request_definition]
2+
r = sub, obj, act
3+
4+
[policy_definition]
5+
p = sub, obj, act
6+
7+
[role_definition]
8+
g = _, _
9+
10+
[policy_effect]
11+
e = some(where (p.eft == allow))
12+
13+
[matchers]
14+
m = g(r.sub, p.sub) && r.obj == p.obj && r.act == p.act

examples/rbac_policy.csv

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
p, alice, data1, read
2+
p, bob, data2, write
3+
p, data2_admin, data2, read
4+
p, data2_admin, data2, write
5+
g, alice, data2_admin
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[request_definition]
2+
r = sub, dom, obj, act
3+
4+
[policy_definition]
5+
p = sub, dom, obj, act
6+
7+
[role_definition]
8+
g = _, _, _
9+
10+
[policy_effect]
11+
e = some(where (p.eft == allow))
12+
13+
[matchers]
14+
m = g(r.sub, p.sub, r.dom) && r.dom == p.dom && r.obj == p.obj && r.act == p.act
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
p, admin, domain1, data1, read
2+
p, admin, domain1, data1, write
3+
p, admin, domain2, data2, read
4+
p, admin, domain2, data2, write
5+
g, alice, admin, domain1
6+
g, bob, admin, domain2

maven-settings.xml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<settings>
2+
<servers>
3+
<server>
4+
<id>ossrh</id>
5+
<username>${OSSRH_JIRA_USERNAME}</username>
6+
<password>${OSSRH_JIRA_PASSWORD}</password>
7+
</server>
8+
</servers>
9+
<profiles>
10+
<profile>
11+
<id>ossrh</id>
12+
<activation>
13+
<activeByDefault>true</activeByDefault>
14+
</activation>
15+
<properties>
16+
<gpg.executable>gpg</gpg.executable>
17+
<gpg.keyname>${GPG_KEY_NAME}</gpg.keyname>
18+
<gpg.passphrase>${GPG_PASSPHRASE}</gpg.passphrase>
19+
</properties>
20+
</profile>
21+
</profiles>
22+
</settings>

pom.xml

Lines changed: 229 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,229 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>org.casbin</groupId>
8+
<artifactId>play-authz</artifactId>
9+
<version>0.0.1</version>
10+
11+
<name>play authz</name>
12+
<description>Provides jcasbin support to Play Framework.</description>
13+
<url>https://github.com/jcasbin/play-authz</url>
14+
<inceptionYear>2022</inceptionYear>
15+
16+
<issueManagement>
17+
<system>Github</system>
18+
<url>https://github.com/jcasbin/play-authz/issues</url>
19+
</issueManagement>
20+
21+
<parent>
22+
<groupId>org.sonatype.oss</groupId>
23+
<artifactId>oss-parent</artifactId>
24+
<version>7</version>
25+
</parent>
26+
<licenses>
27+
<license>
28+
<name>The Apache Software License, Version 2.0</name>
29+
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
30+
<distribution>repo</distribution>
31+
</license>
32+
</licenses>
33+
<scm>
34+
<url>https://github.com/jcasbin/play-authz</url>
35+
<connection>https://github.com/jcasbin/play-authz.git</connection>
36+
<developerConnection>https://github.com/hsluoyz</developerConnection>
37+
</scm>
38+
<developers>
39+
<developer>
40+
<name>Yang Luo</name>
41+
<email>hsluoyz@qq.com</email>
42+
<url>https://github.com/hsluoyz</url>
43+
</developer>
44+
</developers>
45+
46+
<properties>
47+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
48+
</properties>
49+
50+
<distributionManagement>
51+
<snapshotRepository>
52+
<id>ossrh</id>
53+
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
54+
</snapshotRepository>
55+
<repository>
56+
<id>ossrh</id>
57+
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
58+
</repository>
59+
</distributionManagement>
60+
61+
<build>
62+
<plugins>
63+
<plugin>
64+
<groupId>org.apache.maven.plugins</groupId>
65+
<artifactId>maven-gpg-plugin</artifactId>
66+
<version>1.5</version>
67+
<executions>
68+
<execution>
69+
<id>sign-artifacts</id>
70+
<phase>verify</phase>
71+
<goals>
72+
<goal>sign</goal>
73+
</goals>
74+
</execution>
75+
</executions>
76+
<configuration>
77+
<!-- Prevent gpg from using pinentry programs -->
78+
<gpgArguments>
79+
<arg>--pinentry-mode</arg>
80+
<arg>loopback</arg>
81+
</gpgArguments>
82+
</configuration>
83+
</plugin>
84+
<plugin>
85+
<groupId>org.eluder.coveralls</groupId>
86+
<artifactId>coveralls-maven-plugin</artifactId>
87+
<version>4.3.0</version>
88+
</plugin>
89+
<plugin>
90+
<groupId>org.jacoco</groupId>
91+
<artifactId>jacoco-maven-plugin</artifactId>
92+
<version>0.7.6.201602180812</version>
93+
<executions>
94+
<execution>
95+
<id>prepare-agent</id>
96+
<goals>
97+
<goal>prepare-agent</goal>
98+
</goals>
99+
</execution>
100+
</executions>
101+
</plugin>
102+
<plugin>
103+
<!-- Allow attaching Javadoc during releases -->
104+
<groupId>org.apache.maven.plugins</groupId>
105+
<artifactId>maven-javadoc-plugin</artifactId>
106+
<version>2.10.4</version>
107+
<configuration>
108+
<source>11</source>
109+
<detectJavaApiLink>false</detectJavaApiLink>
110+
<!-- Turn off Java 8 strict Javadoc checking -->
111+
<additionalparam>-Xdoclint:none</additionalparam>
112+
<tags>
113+
<tag>
114+
<name>notnull</name>
115+
<placement>a</placement>
116+
<head>Not null</head>
117+
</tag>
118+
<tag>
119+
<name>default</name>
120+
<placement>a</placement>
121+
<head>Default:</head>
122+
</tag>
123+
</tags>
124+
</configuration>
125+
<executions>
126+
<!-- Compress Javadoc into JAR and include that JAR when deploying. -->
127+
<execution>
128+
<id>attach-javadocs</id>
129+
<goals>
130+
<goal>jar</goal>
131+
</goals>
132+
</execution>
133+
</executions>
134+
</plugin>
135+
<plugin>
136+
<!-- Include zipped source code in releases -->
137+
<groupId>org.apache.maven.plugins</groupId>
138+
<artifactId>maven-source-plugin</artifactId>
139+
<executions>
140+
<execution>
141+
<id>attach-sources</id>
142+
<goals>
143+
<goal>jar-no-fork</goal>
144+
</goals>
145+
</execution>
146+
</executions>
147+
</plugin>
148+
<plugin>
149+
<!-- Automatically close and deploy from OSSRH -->
150+
<groupId>org.sonatype.plugins</groupId>
151+
<artifactId>nexus-staging-maven-plugin</artifactId>
152+
<version>1.6.7</version>
153+
<extensions>true</extensions>
154+
<configuration>
155+
<serverId>ossrh</serverId>
156+
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
157+
<!-- Release versions will be synced to Maven Central automatically. -->
158+
<autoReleaseAfterClose>true</autoReleaseAfterClose>
159+
</configuration>
160+
</plugin>
161+
<plugin>
162+
<groupId>org.apache.maven.plugins</groupId>
163+
<artifactId>maven-compiler-plugin</artifactId>
164+
<configuration>
165+
<source>1.8</source>
166+
<target>1.8</target>
167+
</configuration>
168+
</plugin>
169+
<plugin>
170+
<groupId>org.apache.maven.plugins</groupId>
171+
<artifactId>maven-surefire-plugin</artifactId>
172+
<configuration>
173+
<argLine>-Xmx1024m</argLine>
174+
</configuration>
175+
</plugin>
176+
<plugin>
177+
<groupId>org.codehaus.mojo</groupId>
178+
<artifactId>cobertura-maven-plugin</artifactId>
179+
<version>2.7</version>
180+
<configuration>
181+
<formats>
182+
<format>html</format>
183+
<format>xml</format>
184+
</formats>
185+
<check />
186+
</configuration>
187+
</plugin>
188+
</plugins>
189+
</build>
190+
<dependencies>
191+
<dependency>
192+
<groupId>org.casbin</groupId>
193+
<artifactId>jcasbin</artifactId>
194+
<version>1.31.3</version>
195+
</dependency>
196+
<dependency>
197+
<groupId>junit</groupId>
198+
<artifactId>junit</artifactId>
199+
<version>4.13.2</version>
200+
<scope>test</scope>
201+
</dependency>
202+
<dependency>
203+
<groupId>org.casbin</groupId>
204+
<artifactId>jdbc-adapter</artifactId>
205+
<version>2.4.0</version>
206+
</dependency>
207+
<dependency>
208+
<groupId>org.sonatype.sisu</groupId>
209+
<artifactId>sisu-inject-bean</artifactId>
210+
<version>1.4.3.2</version>
211+
</dependency>
212+
<dependency>
213+
<groupId>com.typesafe</groupId>
214+
<artifactId>config</artifactId>
215+
<version>1.3.3</version>
216+
</dependency>
217+
<dependency>
218+
<groupId>org.slf4j</groupId>
219+
<artifactId>slf4j-simple</artifactId>
220+
<version>1.7.36</version>
221+
</dependency>
222+
<dependency>
223+
<groupId>mysql</groupId>
224+
<artifactId>mysql-connector-java</artifactId>
225+
<version>8.0.31</version>
226+
</dependency>
227+
</dependencies>
228+
229+
</project>

0 commit comments

Comments
 (0)