mirror of
https://github.com/kanidm/kanidm.git
synced 2025-02-23 20:47:01 +01:00
Add github actions:
- Add linter with `cargo fmt` - Add tests - Add kanidmd docker build - Add kanidm_rlm_python docker build - Fix kanidm_unix_int format to pass tests
This commit is contained in:
parent
cfdaa702e5
commit
911b5983aa
75
.github/workflows/kanidmd-docker_image.yml
vendored
Normal file
75
.github/workflows/kanidmd-docker_image.yml
vendored
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
name: Docker
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
# Publish `master` as Docker `latest` image.
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
# Publish `v1.2.3` tags as releases.
|
||||||
|
tags:
|
||||||
|
- v*
|
||||||
|
|
||||||
|
# Run tests for any PRs.
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
env:
|
||||||
|
IMAGE_NAME: ${{ secrets.DOCKERHUB_USERNAME }}/server
|
||||||
|
DOCKERFILE_DIR: kanidmd
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
# Run tests.
|
||||||
|
# See also https://docs.docker.com/docker-hub/builds/automated-testing/
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: |
|
||||||
|
if [ -f docker-compose.test.yml ]; then
|
||||||
|
docker-compose --file docker-compose.test.yml build
|
||||||
|
docker-compose --file docker-compose.test.yml run sut
|
||||||
|
else
|
||||||
|
docker build . --file $DOCKERFILE_DIR/Dockerfile
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Push image to GitHub Packages.
|
||||||
|
# See also https://docs.docker.com/docker-hub/builds/
|
||||||
|
push:
|
||||||
|
# Ensure test job passes before pushing image.
|
||||||
|
needs: test
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: github.event_name == 'push'
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Build image
|
||||||
|
run: docker build . --file $DOCKERFILE_DIR/Dockerfile --tag image
|
||||||
|
|
||||||
|
- name: Log into registry
|
||||||
|
run: echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
|
||||||
|
|
||||||
|
- name: Push image
|
||||||
|
run: |
|
||||||
|
# Change all uppercase to lowercase
|
||||||
|
IMAGE_ID=$(echo $IMAGE_NAME | tr '[A-Z]' '[a-z]')
|
||||||
|
|
||||||
|
# Strip git ref prefix from version
|
||||||
|
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
|
||||||
|
|
||||||
|
# Strip "v" prefix from tag name
|
||||||
|
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
|
||||||
|
|
||||||
|
# Use Docker `latest` tag convention
|
||||||
|
[ "$VERSION" == "master" ] && VERSION=latest
|
||||||
|
|
||||||
|
echo IMAGE_ID=$IMAGE_ID
|
||||||
|
echo VERSION=$VERSION
|
||||||
|
|
||||||
|
docker tag image $IMAGE_ID:$VERSION
|
||||||
|
docker push $IMAGE_ID:$VERSION
|
||||||
|
|
75
.github/workflows/radius-docker_image.yml
vendored
Normal file
75
.github/workflows/radius-docker_image.yml
vendored
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
name: Docker
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
# Publish `master` as Docker `latest` image.
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
# Publish `v1.2.3` tags as releases.
|
||||||
|
tags:
|
||||||
|
- v*
|
||||||
|
|
||||||
|
# Run tests for any PRs.
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
env:
|
||||||
|
IMAGE_NAME: ${{ secrets.DOCKERHUB_USERNAME }}/radius
|
||||||
|
DOCKERFILE_DIR: kanidm_rlm_python
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
# Run tests.
|
||||||
|
# See also https://docs.docker.com/docker-hub/builds/automated-testing/
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: |
|
||||||
|
if [ -f docker-compose.test.yml ]; then
|
||||||
|
docker-compose --file docker-compose.test.yml build
|
||||||
|
docker-compose --file docker-compose.test.yml run sut
|
||||||
|
else
|
||||||
|
cd $DOCKERFILE_DIR && docker build . --file Dockerfile
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Push image to GitHub Packages.
|
||||||
|
# See also https://docs.docker.com/docker-hub/builds/
|
||||||
|
push:
|
||||||
|
# Ensure test job passes before pushing image.
|
||||||
|
needs: test
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: github.event_name == 'push'
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Build image
|
||||||
|
run: cd $DOCKERFILE_DIR && docker build . --file Dockerfile --tag image
|
||||||
|
|
||||||
|
- name: Log into registry
|
||||||
|
run: echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
|
||||||
|
|
||||||
|
- name: Push image
|
||||||
|
run: |
|
||||||
|
# Change all uppercase to lowercase
|
||||||
|
IMAGE_ID=$(echo $IMAGE_NAME | tr '[A-Z]' '[a-z]')
|
||||||
|
|
||||||
|
# Strip git ref prefix from version
|
||||||
|
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
|
||||||
|
|
||||||
|
# Strip "v" prefix from tag name
|
||||||
|
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
|
||||||
|
|
||||||
|
# Use Docker `latest` tag convention
|
||||||
|
[ "$VERSION" == "master" ] && VERSION=latest
|
||||||
|
|
||||||
|
echo IMAGE_ID=$IMAGE_ID
|
||||||
|
echo VERSION=$VERSION
|
||||||
|
|
||||||
|
docker tag image $IMAGE_ID:$VERSION
|
||||||
|
docker push $IMAGE_ID:$VERSION
|
||||||
|
|
43
.github/workflows/rust.yml
vendored
Normal file
43
.github/workflows/rust.yml
vendored
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
name: Rust
|
||||||
|
|
||||||
|
# Trigger the workflow on push or pull request
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
fmt:
|
||||||
|
name: Rustfmt
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout sources
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Install stable toolchain
|
||||||
|
uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: stable
|
||||||
|
override: true
|
||||||
|
|
||||||
|
- name: Install rustfmt
|
||||||
|
run: rustup component add rustfmt
|
||||||
|
|
||||||
|
- name: Run cargo fmt
|
||||||
|
run: cargo fmt --all -- --check
|
||||||
|
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
sudo apt install -y \
|
||||||
|
libsqlite3-dev \
|
||||||
|
libpam0g-dev \
|
||||||
|
libssl1.0-dev
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: cargo build --verbose
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: cargo test --verbose
|
||||||
|
|
|
@ -241,13 +241,11 @@ async fn main() {
|
||||||
match socket_res {
|
match socket_res {
|
||||||
Ok(socket) => {
|
Ok(socket) => {
|
||||||
let cachelayer_ref = cachelayer.clone();
|
let cachelayer_ref = cachelayer.clone();
|
||||||
tokio::spawn(
|
tokio::spawn(async move {
|
||||||
async move {
|
if let Err(e) = handle_client(socket, cachelayer_ref.clone()).await {
|
||||||
if let Err(e) = handle_client(socket, cachelayer_ref.clone()).await {
|
error!("an error occured; error = {:?}", e);
|
||||||
error!("an error occured; error = {:?}", e);
|
}
|
||||||
}
|
});
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
error!("Accept error -> {:?}", err);
|
error!("Accept error -> {:?}", err);
|
||||||
|
|
Loading…
Reference in a new issue