-
Notifications
You must be signed in to change notification settings - Fork 18
146 lines (129 loc) · 5.79 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
name: CI
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
build:
name: Auto Build CI
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macOS-latest ]
rust: [ stable, beta, nightly ]
steps:
- name: Checkout Repository
uses: actions/checkout@master
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
components: rustfmt, clippy
override: true
- name: Setup PostgreSQL & MySQL & SQLite (for ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y libpq-dev postgresql libsqlite3-dev sqlite3 libmysqlclient-dev
echo "host all all 127.0.0.1/32 md5" > sudo tee -a /etc/postgresql/10/main/pg_hba.conf
sudo service postgresql restart && sleep 3
sudo -u postgres createuser casbin_rs
sudo -u postgres createdb casbin
sudo -u postgres psql -c "alter user casbin_rs with encrypted password 'casbin_rs'; grant all privileges on database casbin to casbin_rs;"
sudo service postgresql restart && sleep 3
sudo systemctl start mysql.service
sudo apt-get update
sudo apt-get -y install libmysqlclient-dev
mysql -e "create user 'casbin_rs'@'localhost' identified by 'casbin_rs'; create database casbin; grant all on \`casbin\`.* to 'casbin_rs'@'localhost';" -uroot -proot
- name: Setup PostgreSQL & MySQL & SQLite (for macOS)
if: matrix.os == 'macOS-latest'
run: |
brew update
brew install [email protected] sqlite
mkdir -p /usr/local/var/postgres
initdb /usr/local/var/postgres
pg_ctl -D /usr/local/var/postgres start
sleep 3
createuser casbin_rs
createdb casbin
psql postgres -c "alter user casbin_rs with encrypted password 'casbin_rs'; grant all privileges on database casbin to casbin_rs;"
/usr/local/opt/[email protected]/bin/mysql_install_db
/usr/local/opt/[email protected]/bin/mysql.server start
sleep 3
/usr/local/opt/[email protected]/bin/mysql -e "create user 'casbin_rs'@'localhost' identified by 'casbin_rs'; create database casbin; grant all on \`casbin\`.* to 'casbin_rs'@'localhost';" -urunner
echo "MYSQLCLIENT_LIB_DIR=/usr/local/opt/[email protected]/lib" >> $GITHUB_ENV
brew link --overwrite [email protected]
- name: Setup PostgreSQL & MySQL & SQLite (for windows)
if: matrix.os == 'windows-latest'
shell: cmd
run: |
choco install postgresql11 --force --params '/Password:root'
choco install mysql sqlite
"C:\Program Files\PostgreSQL\11\bin\createuser" casbin_rs
"C:\Program Files\PostgreSQL\11\bin\createdb" casbin
"C:\Program Files\PostgreSQL\11\bin\psql" -c "alter user casbin_rs with encrypted password 'casbin_rs'; grant all privileges on database casbin to casbin_rs;"
"C:\tools\mysql\current\bin\mysql" -e "create user 'casbin_rs'@'localhost' identified by 'casbin_rs'; create database casbin; grant all on `casbin`.* to 'casbin_rs'@'localhost';" -uroot
cd /D C:\ProgramData\chocolatey\lib\SQLite\tools
dir "C:\Program Files\Microsoft Visual Studio"
dir "C:\Program Files\Microsoft Visual Studio\2022"
dir "C:\Program Files\Microsoft Visual Studio\2022\Enterprise"
dir "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC"
dir "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary"
dir "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build"
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
lib /machine:x64 /def:sqlite3.def /out:sqlite3.lib
- name: Set environment variables (for windows)
if: matrix.os == 'windows-latest'
shell: bash
run: |
echo "PQ_LIB_DIR=C:\Program Files\PostgreSQL\11\lib" >> $GITHUB_ENV
echo "MYSQLCLIENT_LIB_DIR=C:\tools\mysql\current\lib" >> $GITHUB_ENV
echo "SQLITE3_LIB_DIR=C:\ProgramData\chocolatey\lib\SQLite\tools" >> $GITHUB_ENV
- name: Cargo Build
uses: actions-rs/cargo@v1
with:
command: build
- name: Cargo Test For PostgreSQL,async-std
uses: actions-rs/cargo@v1
with:
command: test
args: --no-default-features --features postgres,runtime-async-std
- name: Cargo Test For PostgreSQL,tokio
uses: actions-rs/cargo@v1
with:
command: test
args: --no-default-features --features postgres,runtime-tokio
- name: Cargo Test For MySQL,async-std
uses: actions-rs/cargo@v1
with:
command: test
args: --no-default-features --features mysql,runtime-async-std
- name: Cargo Test For MySQL,tokio
uses: actions-rs/cargo@v1
with:
command: test
args: --no-default-features --features mysql,runtime-tokio
- name: Cargo Test For SQLite,async-std
uses: actions-rs/cargo@v1
with:
command: test
args: --no-default-features --features sqlite,runtime-async-std
- name: Cargo Test For SQLite,tokio
uses: actions-rs/cargo@v1
with:
command: test
args: --no-default-features --features sqlite,runtime-tokio
- name: Cargo Clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: -- -D warnings
- name: Cargo Fmt Check
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check