mirror of
https://codeberg.org/demostf/api-client.git
synced 2026-06-03 08:34:15 +02:00
add github actions ci
This commit is contained in:
parent
16637e31f5
commit
59c9efe395
4 changed files with 73 additions and 39 deletions
66
.github/workflows/rust.yml
vendored
Normal file
66
.github/workflows/rust.yml
vendored
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
on: [push, pull_request]
|
||||
|
||||
name: CI
|
||||
|
||||
jobs:
|
||||
check:
|
||||
name: Check
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: stable
|
||||
override: true
|
||||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: check
|
||||
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
name: Tests
|
||||
|
||||
services:
|
||||
api-test-db:
|
||||
image: demostf/db
|
||||
env:
|
||||
POSTGRES_PASSWORD: test
|
||||
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
|
||||
ports:
|
||||
- 5432:5432
|
||||
api:
|
||||
image: demostf/api
|
||||
env:
|
||||
DEMO_ROOT: /tmp
|
||||
DEMO_HOST: localhost
|
||||
DB_TYPE: pgsql
|
||||
DB_HOST: api-test-db
|
||||
DB_PORT: 5432
|
||||
DB_DATABASE: postgres
|
||||
DB_USERNAME: postgres
|
||||
DB_PASSWORD: test
|
||||
APP_ROOT: https://api.localhost
|
||||
EDIT_SECRET: edit
|
||||
api-test:
|
||||
image: demostf/api-nginx-test
|
||||
env:
|
||||
POSTGRES_PASSWORD: test
|
||||
ports:
|
||||
- 80:80
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
- uses: actions-rs/cargo@v1
|
||||
env:
|
||||
DB_URL: postgres://postgres:test@localhost/postgres
|
||||
API_ROOT: http://localhost/
|
||||
with:
|
||||
command: test
|
||||
args: -- --test-threads 1
|
||||
- name: logs
|
||||
uses: jwalton/gh-docker-logs@v1
|
||||
if: failure()
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
root /usr/share/nginx/html;
|
||||
|
||||
client_max_body_size 200m;
|
||||
|
||||
if ($request_method = POST ) {
|
||||
rewrite /upload /do_upload last;
|
||||
break;
|
||||
}
|
||||
|
||||
location /do_upload {
|
||||
fastcgi_pass api:9000;
|
||||
fastcgi_index index.php;
|
||||
include fastcgi_params;
|
||||
fastcgi_param SCRIPT_FILENAME /app/src/public/upload.php;
|
||||
}
|
||||
|
||||
index index.php;
|
||||
|
||||
try_files $uri /index.php?$query_string /index.php;
|
||||
|
||||
location ~ ^(.+?\.php)(/.*)?$ {
|
||||
fastcgi_param PATH_INFO $2;
|
||||
fastcgi_pass api:9000;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_param SCRIPT_FILENAME /app/src/public/index.php;
|
||||
include fastcgi_params;
|
||||
}
|
||||
}
|
||||
|
|
@ -13,5 +13,4 @@ docker run -d --name api-test-fpm --link api-test-db:db -v /tmp/api-test-data:/d
|
|||
-e DB_HOST=db -e DB_PORT=5432 -e DB_DATABASE=postgres -e DB_USERNAME=postgres \
|
||||
-e DB_PASSWORD=test -e APP_ROOT=http://api.localhost -e EDIT_SECRET=edit \
|
||||
demostf/api
|
||||
docker run -d --name api-test --link api-test-fpm:api\
|
||||
-v $(pwd)/nginx_test.conf:/etc/nginx/conf.d/api.conf:ro -p 8888:80 nginx
|
||||
docker run -d --name api-test --link api-test-fpm:api -p 8888:80 demostf/api-nginx-test
|
||||
|
|
|
|||
|
|
@ -146,12 +146,12 @@ async fn test_get_demo() {
|
|||
SteamID::from(76561198024494988)
|
||||
);
|
||||
|
||||
let players = &demo.players;
|
||||
dbg!(players);
|
||||
let mut players = demo.players;
|
||||
players.sort_by(|a, b| a.player_id.cmp(&b.player_id));
|
||||
|
||||
assert_eq!(demo.players[0].player_id, 1);
|
||||
assert_eq!(demo.players[0].user.id, 2);
|
||||
assert_eq!(demo.players[0].user.name, "distraughtduck4");
|
||||
assert_eq!(players[0].player_id, 1);
|
||||
assert_eq!(players[0].user.id, 2);
|
||||
assert_eq!(players[0].user.name, "distraughtduck4");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
|
|
@ -186,7 +186,7 @@ async fn test_set_url_invalid_key() {
|
|||
|
||||
let res = client
|
||||
.set_url(
|
||||
9,
|
||||
1,
|
||||
"tests",
|
||||
"tests",
|
||||
"http://example.com/tests",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue