Update Github CI configuration

This commit is contained in:
2022-04-05 21:04:42 +02:00
parent 33401b3d39
commit 6f85e2eb46
8 changed files with 125 additions and 85 deletions

View File

@@ -1,22 +0,0 @@
name: 'cargo tarpaulin'
description: 'Gather Rust code coverage information with Tarpaulin'
inputs:
version:
description: 'The version of cargo-tarpaulin to install'
required: true
default: '0.19.0'
args:
required: false
description: 'Extra command line arguments passed to cargo-tarpaulin'
out-type:
description: 'Output format of coverage report [possible values: Json, Toml, Stdout, Xml, Html, Lcov]'
required: false
default: 'Xml'
runs:
using: 'composite'
steps:
- run: ${{ github.action_path }}/cargo-tarpaulin.sh ${{ inputs.out-type }} ${{ inputs.version }} ${{ inputs.args }}
shell: bash

View File

@@ -1,15 +0,0 @@
#!/bin/bash
sudo apt-get update -y
sudo apt-get install -y --no-install-recommends openssl taskwarrior
out_type="$1"
version="$2"
args="$3"
tar_file="cargo-tarpaulin-${version}-travis.tar.gz"
wget "https://github.com/xd009642/tarpaulin/releases/download/${version}/${tar_file}"
tar zxvf "$tar_file"
chmod +x cargo-tarpaulin
exec env RUST_LOG=debug ./cargo-tarpaulin tarpaulin --ignore-tests -o "$out_type" $args

View File

@@ -10,7 +10,15 @@ jobs:
security_audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- uses: Swatinem/rust-cache@v1
- uses: actions-rs/audit-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -1,57 +1,126 @@
on: [push]
name: CI
on:
push:
branches:
- main
pull_request:
jobs:
format:
name: rustfmt
rustfmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
components: rustfmt
override: true
- uses: LoliGothick/rustfmt-check@v0.2
with:
token: ${{ secrets.GITHUB_TOKEN }}
flags: --all
options: --manifest-path=Cargo.toml
build_and_test:
name: Build & test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: clippy
profile: minimal
components: rustfmt
- name: Check formatting
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
- name: Install Wasm Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
target: wasm32-unknown-unknown
- uses: Swatinem/rust-cache@v1
with:
sharedKey: ci
- uses: actions-rs/cargo@v1
with:
command: build
args: --release --all-features
args: --all-features --workspace
- uses: actions-rs/clippy-check@v1
test:
needs: build
name: Test Suite
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --tests -- -D warnings
toolchain: stable
profile: minimal
- uses: awalsh128/cache-apt-pkgs-action@v1
with:
packages: taskwarrior
version: 1.0
- uses: Swatinem/rust-cache@v1
with:
sharedKey: ci
- uses: actions-rs/cargo@v1
with:
command: test
args: --all-features --workspace
clippy:
needs: build
name: Clippy
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
components: clippy
- uses: Swatinem/rust-cache@v1
with:
sharedKey: ci
- name: Clippy check
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-targets --all-features --workspace -- -D warnings
coverage:
name: Code coverage
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
- uses: awalsh128/cache-apt-pkgs-action@v1
with:
packages: taskwarrior
version: 1.0
- uses: Swatinem/rust-cache@v1
- name: Run cargo-tarpaulin
uses: ./.github/actions/cargo-tarpaulin-action/
uses: actions-rs/tarpaulin@v0.1
with:
args: '-- --test-threads 1'
- name: Upload to codecov.io
uses: codecov/codecov-action@v1.0.2
args: '--all-features --workspace --ignore-tests --out Lcov'
- name: Upload to Coveralls
# upload only if push
if: ${{ github.event_name == 'push' }}
uses: coverallsapp/github-action@master
with:
token: ${{secrets.CODECOV_TOKEN}}
- name: Archive code coverage results
uses: actions/upload-artifact@v1
with:
name: code-coverage-report
path: cobertura.xml
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: './lcov.info'

View File

@@ -1,8 +1,8 @@
# Contextswitch
[![AGPL License](https://img.shields.io/badge/license-AGPL-blue.svg)](http://www.gnu.org/licenses/agpl-3.0)
[![codecov](https://codecov.io/gh/dax/contextswitch/branch/main/graph/badge.svg?token=CHUSURDB5Q)](https://codecov.io/gh/dax/contextswitch)
![CI](https://github.com/dax/contextswitch/actions/workflows/ci.yml/badge.svg)
[![Coverage Status](https://coveralls.io/repos/github/dax/contextswitch/badge.svg?branch=main)](https://coveralls.io/github/dax/contextswitch?branch=main)
[![CI](https://github.com/dax/contextswitch/workflows/CI/badge.svg)](https://github.com/dax/contextswitch/actions)
Contextswitch is a todo list application linking bookmarks to a task.
Integrations with third parties applications add context to a task:

View File

@@ -29,7 +29,7 @@ impl Settings {
let config_file_required = file.is_some();
let config_path = env::var("CONFIG_PATH").unwrap_or_else(|_| "config".into());
let config_file = file.unwrap_or_else(|| {
env::var("CONFIG_FILE").unwrap_or_else(|_| format!("{}/dev", &config_path).into())
env::var("CONFIG_FILE").unwrap_or_else(|_| format!("{}/dev", &config_path))
});
let default_config_file = format!("{}/default", config_path);

View File

@@ -55,9 +55,9 @@ pub fn run(listener: TcpListener, settings: &Settings) -> Result<Server, std::io
if let Some(path) = &static_path {
info!(
"Mounting static files on {}",
if path.is_empty() { "/" } else { &path }
if path.is_empty() { "/" } else { path }
);
let static_scope = fs::Files::new(&path, &static_dir)
let static_scope = fs::Files::new(path, &static_dir)
.use_last_modified(true)
.index_file("index.html");
app = app.service(static_scope);

View File

@@ -17,7 +17,7 @@ fn setup_server(settings: &Settings) -> String {
let listener = TcpListener::bind("127.0.0.1:0").expect("Failed to bind random port");
let port = listener.local_addr().unwrap().port();
let server = contextswitch_api::run(listener, &settings).expect("Failed to bind address");
let server = contextswitch_api::run(listener, settings).expect("Failed to bind address");
let _ = tokio::spawn(server);
format!("http://127.0.0.1:{}", port)
}