Skip to content

Commit 42702f3

Browse files
authored
# Setting up testing actions, generate unit tests for the projects, correct clippy warnings and format according rustfmt (#21)
* #feature - setting up worflows for multiple different OS and Rust versions * #feature - code-quality workflow for lint with Clippy, and formatting with rustfmt. OS independent tests only gets triggered on push tags, just for reflecting the status badge for every new release. A new continuous-integration workflow runs now on every push and PR, being the default required statuses to pass before do anything against the main branch * #feature Added cache for multiple jobs on the new workflows * #Fix - Solved clippy warnings on the project * #feature - formatted project with rustmt * #feature - psql docker now has config for have an static ip * #feature - Integration Tests for the base CRUD operations available in Canyon-SQL. * #fix - Corrected macro paths to canyon_sql::bounds on the macro insert operations generator
1 parent 9709017 commit 42702f3

71 files changed

Lines changed: 10711 additions & 2003 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{
2+
"categories": [
3+
{
4+
"title": "## 🚀 Features",
5+
"labels": ["feature"]
6+
},
7+
{
8+
"title": "## 🐛 Fixes",
9+
"labels": ["fix"]
10+
},
11+
{
12+
"title": "## 🧪 Tests",
13+
"labels": ["test"]
14+
},
15+
{
16+
"title": "## 🧪 Tests and some 🪄 Magic",
17+
"labels": ["test", "magic"],
18+
"exclude_labels": ["no-magic"],
19+
"exhaustive": true,
20+
"empty_content": "- no matching PRs"
21+
}
22+
],
23+
"ignore_labels": [
24+
"ignore"
25+
],
26+
"sort": {
27+
"order": "ASC",
28+
"on_property": "mergedAt"
29+
},
30+
"template": "${{CHANGELOG}}\n\n<details>\n<summary>Uncategorized</summary>\n\n${{UNCATEGORIZED}}\n</details>",
31+
"pr_template": "- ${{TITLE}}\n - PR: #${{NUMBER}}",
32+
"empty_template": "- no changes",
33+
"label_extractor": [
34+
{
35+
"pattern": "(.) (.+)",
36+
"target": "$1",
37+
"flags": "gu"
38+
},
39+
{
40+
"pattern": "\\[Issue\\]",
41+
"on_property": "title",
42+
"method": "match"
43+
}
44+
],
45+
"duplicate_filter": {
46+
"pattern": "\\[ABC-....\\]",
47+
"on_property": "title",
48+
"method": "match"
49+
},
50+
"transformers": [
51+
{
52+
"pattern": "[\\-\\*] (\\[(...|TEST|CI|SKIP)\\])( )?(.+?)\n(.+?[\\-\\*] )(.+)",
53+
"target": "- $4\n - $6"
54+
}
55+
],
56+
"max_tags_to_fetch": 200,
57+
"max_pull_requests": 200,
58+
"max_back_track_time_days": 365,
59+
"exclude_merge_branches": [
60+
"Owner/qa"
61+
],
62+
"tag_resolver": {
63+
"method": "semver",
64+
"filter": {
65+
"pattern": "api-(.+)",
66+
"flags": "gu"
67+
}
68+
},
69+
"base_branches": [
70+
"dev"
71+
]
72+
}

.github/workflows/cache.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Linux CI && Code Coverage
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v[0-9]+.[0-9]+.[0-9]+'
7+
- 'v[0-9]+.[0-9]+.[0-9]+rc[0-9]+'
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
jobs:
13+
code-coverage:
14+
permissions:
15+
contents: write
16+
env:
17+
CARGO_INCREMENTAL: '0'
18+
RUSTFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests'
19+
RUSTDOCFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests'
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v3
23+
24+
- name: Use nightly toolchain
25+
run: |
26+
rustup toolchain install nightly
27+
rustup override set nightly
28+
29+
- name: Caching cargo dependencies
30+
id: project-cache
31+
uses: Swatinem/rust-cache@v2
32+
33+
- if: ${{ steps.cache-cargo.outputs.cache-hit != 'true' }}
34+
name: Install grcov
35+
run: cargo install grcov
36+
37+
- name: Make the USER own the working directory
38+
if: ${{ matrix.os == 'ubuntu-latest' }}
39+
run: sudo chown -R $USER:$USER ${{ github.workspace }}
40+
41+
- name: Waking up docker
42+
run: docker-compose -f ./docker/docker-compose.yml up -d
43+
44+
- name: Run tests
45+
run: |
46+
cargo test --all-features --no-fail-fast --target=x86_64-unknown-linux-gnu -- --show-output --test-threads=1
47+
48+
- name: Waking up docker
49+
run: |
50+
docker-compose -f ./docker/docker-compose.yml down
51+
sudo chown -R $USER:$USER ${{ github.workspace }}
52+
rm -rf ./docker/postgres-data
53+
54+
- name: Generate code coverage report
55+
run: |
56+
grcov . -s . --binary-path ./target/debug/ -t html --branch --ignore-not-existing -o ./target/debug/coverage
57+
grcov . -s . --binary-path ./target/debug/ -t cobertura --branch --ignore-not-existing -o ./target/debug/coverage/code_cov.xml
58+
59+
- name: Publish Test Results
60+
uses: actions/upload-artifact@v3
61+
with:
62+
name: Unit Test Results
63+
path: |
64+
./target/debug/coverage/code_cov.xml
65+
./target/debug/coverage/index.html
66+
67+
- name: Publish coverage report to GitHub Pages
68+
uses: JamesIves/github-pages-deploy-action@v4
69+
with:
70+
folder: ./target/debug/coverage
71+
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/code-quality.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Code quality and sanity
2+
3+
on:
4+
push:
5+
branches: '*'
6+
pull_request:
7+
branches: '*'
8+
9+
jobs:
10+
clippy:
11+
name: Lint with Clippy
12+
runs-on: ubuntu-latest
13+
env:
14+
RUSTFLAGS: -Dwarnings
15+
steps:
16+
- uses: actions/checkout@v3
17+
18+
- name: Caching project dependencies
19+
id: project-cache
20+
uses: Swatinem/rust-cache@v2
21+
22+
- uses: hecrj/setup-rust-action@v1
23+
with:
24+
components: clippy
25+
- run: cargo clippy --workspace --all-targets --verbose --all-features -- -A clippy::question_mark
26+
rustfmt:
27+
name: Verify code formatting
28+
runs-on: ubuntu-latest
29+
steps:
30+
- uses: actions/checkout@v3
31+
32+
- name: Caching project dependencies
33+
id: project-cache
34+
uses: Swatinem/rust-cache@v2
35+
36+
- uses: hecrj/setup-rust-action@v1
37+
with:
38+
components: rustfmt
39+
40+
- run: cargo fmt --all -- --check
41+
42+
check-rustdoc-links:
43+
name: Check intra-doc links
44+
runs-on: ubuntu-latest
45+
strategy:
46+
fail-fast: false
47+
matrix:
48+
crate: [canyon_connection, canyon_crud, canyon_macros, canyon_observer, canyon_manager, canyon_observer, canyon_sql]
49+
steps:
50+
- uses: actions/checkout@v3
51+
52+
- name: Caching project dependencies
53+
id: project-cache
54+
uses: Swatinem/rust-cache@v2
55+
56+
- uses: hecrj/setup-rust-action@v1
57+
with:
58+
rust-version: nightly
59+
60+
- run: cargo rustdoc -p ${{ matrix.crate }} --all-features -- -D warnings
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Continuous Integration
2+
3+
on:
4+
push:
5+
branches: 'main'
6+
pull_request:
7+
branches: 'main'
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
jobs:
13+
multiplatform-tests:
14+
name: Testing on Rust ${{ matrix.rust }} for ${{ matrix.os }}
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
include:
20+
- { rust: stable, os: ubuntu-latest }
21+
- { rust: nightly, os: ubuntu-latest }
22+
- { rust: stable, os: macos-latest }
23+
- { rust: stable, os: windows-latest }
24+
25+
steps:
26+
- name: Make the USER own the working directory
27+
if: ${{ matrix.os == 'ubuntu-latest' }}
28+
run: sudo chown -R $USER:$USER ${{ github.workspace }}
29+
30+
- uses: actions/checkout@v3
31+
32+
- name: docker-compose
33+
if: ${{ matrix.os == 'ubuntu-latest' }}
34+
run: docker-compose -f ./docker/docker-compose.yml up -d
35+
36+
- name: Caching cargo dependencies
37+
id: project-cache
38+
uses: Swatinem/rust-cache@v2
39+
40+
- uses: hecrj/setup-rust-action@v1
41+
with:
42+
rust-version: ${{ matrix.rust }}
43+
44+
- name: Run all tests, UNIT and INTEGRATION for Linux targets
45+
if: ${{ matrix.os == 'ubuntu-latest' }}
46+
run: cargo test --verbose --workspace --all-features --no-fail-fast -- --show-output --test-threads=1
47+
48+
- name: Run UNIT tests with no external connections for the rest of the defined targets
49+
if: ${{ matrix.os != 'ubuntu-latest' }}
50+
run: cargo test --verbose --workspace --exclude tests --all-features --no-fail-fast -- --show-output

.github/workflows/macos-tests.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: macOS CI
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v[0-9]+.[0-9]+.[0-9]+'
7+
- 'v[0-9]+.[0-9]+.[0-9]+rc[0-9]+'
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
jobs:
13+
linux-tests:
14+
runs-on: macos-latest
15+
name: Tests for macOS
16+
env:
17+
CARGO_TERM_COLOR: always
18+
steps:
19+
- uses: actions/checkout@v3
20+
21+
- name: Caching cargo deps
22+
id: ci-cache
23+
uses: Swatinem/rust-cache@v2
24+
25+
- name: Running tests for macOS targets
26+
run: |
27+
cargo test --all-features --workspace --exclude tests

.github/workflows/publish-tests-results.yml

Lines changed: 0 additions & 36 deletions
This file was deleted.

.github/workflows/publish.yaml

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)