├── .github
└── workflows
│ └── rust.yml
├── .gitignore
├── .travis.yml
├── .vscode
├── launch.json
└── tasks.json
├── Cargo.toml
├── LICENSE
├── README.md
├── appveyor.yml
├── azure-pipelines.yml
├── codecov.yml
├── medias
└── logo.png
└── rust_oss_template
├── Cargo.toml
└── src
└── lib.rs
/.github/workflows/rust.yml:
--------------------------------------------------------------------------------
1 | name: Rust
2 |
3 | on: [push]
4 |
5 | jobs:
6 | build:
7 |
8 | runs-on: ubuntu-latest
9 |
10 | steps:
11 | - uses: actions/checkout@v1
12 | - name: Cargo build
13 | run: cargo build --all
14 | - name: Cargo test
15 | run: cargo test --all
16 | - name: Run Rustfmt
17 | run: cargo fmt --all -- --check
18 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Generated by Cargo
2 | # will have compiled files and executables
3 | /target/
4 |
5 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
6 | # More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
7 | Cargo.lock
8 |
9 | # These are backup files generated by rustfmt
10 | **/*.rs.bk
11 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: rust
2 |
3 | rust:
4 | - stable
5 | - beta
6 | - nightly
7 |
8 | matrix:
9 | allow_failures:
10 | - rust: nightly
11 |
12 | addons:
13 | apt:
14 | packages:
15 | - libcurl4-openssl-dev
16 | - libelf-dev
17 | - libdw-dev
18 | - cmake
19 | - gcc
20 | - binutils-dev
21 | - libiberty-dev
22 |
23 | after_success: |
24 | wget https://github.com/SimonKagstrom/kcov/archive/master.tar.gz &&
25 | tar xzf master.tar.gz &&
26 | cd kcov-master &&
27 | mkdir build &&
28 | cd build &&
29 | cmake .. &&
30 | make &&
31 | make install DESTDIR=../../kcov-build &&
32 | cd ../.. &&
33 | rm -rf kcov-master &&
34 | for file in target/debug/rust_oss_template-*; do [ -x "${file}" ] || continue; mkdir -p "target/cov/$(basename $file)"; ./kcov-build/usr/local/bin/kcov --exclude-pattern=/.cargo,/usr/lib --verify "target/cov/$(basename $file)" "$file"; done &&
35 | bash <(curl -s https://codecov.io/bash) &&
36 | echo "Uploaded code coverage"
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "0.2.0",
3 | "configurations": [
4 | {
5 | "type": "lldb",
6 | "request": "launch",
7 | "name": "Debug",
8 | "program": "${workspaceRoot}/target/debug/${workspaceFolderBasename}",
9 | "args": [],
10 | "cwd": "${workspaceRoot}",
11 | "preLaunchTask": "build",
12 | "sourceLanguages": ["rust"],
13 | "terminal": "integrated"
14 | }
15 | ]
16 | }
--------------------------------------------------------------------------------
/.vscode/tasks.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0.0",
3 | "tasks": [
4 | {
5 | "label": "build",
6 | "type": "cargo",
7 | "subcommand": "build",
8 | "group": {
9 | "kind": "build",
10 | "isDefault": true
11 | },
12 | "problemMatcher": ["$rustc"]
13 | },
14 | {
15 | "label": "test",
16 | "type": "cargo",
17 | "subcommand": "test",
18 | "group": {
19 | "kind": "test",
20 | "isDefault": true
21 | },
22 | "problemMatcher": ["$rustc"]
23 | }
24 | ]
25 | }
--------------------------------------------------------------------------------
/Cargo.toml:
--------------------------------------------------------------------------------
1 | [workspace]
2 |
3 | members = [
4 | "rust_oss_template"
5 | ]
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Chris Ohk
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # rust-oss-template
2 |
3 |
4 |
5 | [](https://github.com/utilForever/rust-oss-template/blob/master/LICENSE) [](https://travis-ci.org/utilForever/rust-oss-template/branches) [](https://ci.appveyor.com/project/utilForever/rust-oss-template/branch/master) [](https://utilforever.visualstudio.com/rust-oss-template/_build/latest?definitionId=11&branchName=master) [](https://github.com/utilForever/rust-oss-template/actions)
6 |
7 | [](https://codecov.io/gh/utilForever/rust-oss-template)
8 |
9 | rust-oss-template is a simple template for Rust language based project.
10 |
11 | ## Support CI
12 |
13 | - Appveyor
14 | - Travis CI
15 | - Azure Pipelines
16 | - Github Actions
17 |
18 | ## Support Tool
19 |
20 | - Codecov
21 |
22 | ## How To Contribute
23 |
24 | Contributions are always welcome, either reporting issues/bugs or forking the repository and then issuing pull requests when you have completed some additional coding that you feel will be beneficial to the main project. If you are interested in contributing in a more dedicated capacity, then please contact me.
25 |
26 | ## Contact
27 |
28 | You can contact me via e-mail (utilForever at gmail.com). I am always happy to answer questions or help with any issues you might have, and please be sure to share any additional work or your creations with me, I love seeing what other people are making.
29 |
30 | ## References
31 |
32 | - https://github.com/starkat99/appveyor-rust
33 | - https://github.com/codecov/example-rust
34 | - https://nbsoftsolutions.com/blog/azure-pipelines-for-rust-projects
35 |
36 | ## License
37 |
38 |
39 |
40 | The class is licensed under the [MIT License](http://opensource.org/licenses/MIT):
41 |
42 | Copyright © 2019 [Chris Ohk](http://www.github.com/utilForever).
43 |
44 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
45 |
46 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
47 |
48 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
49 |
--------------------------------------------------------------------------------
/appveyor.yml:
--------------------------------------------------------------------------------
1 | # Appveyor configuration template for Rust using rustup for Rust installation
2 | # https://github.com/starkat99/appveyor-rust
3 |
4 | ## Operating System (VM environment) ##
5 |
6 | # Rust needs at least Visual Studio 2013 Appveyor OS for MSVC targets.
7 | os: Visual Studio 2019
8 |
9 | ## Build Matrix ##
10 |
11 | # This configuration will setup a build for each channel & target combination (12 windows
12 | # combinations in all).
13 | #
14 | # There are 3 channels: stable, beta, and nightly.
15 | #
16 | # Alternatively, the full version may be specified for the channel to build using that specific
17 | # version (e.g. channel: 1.5.0)
18 | #
19 | # The values for target are the set of windows Rust build targets. Each value is of the form
20 | #
21 | # ARCH-pc-windows-TOOLCHAIN
22 | #
23 | # Where ARCH is the target architecture, either x86_64 or i686, and TOOLCHAIN is the linker
24 | # toolchain to use, either msvc or gnu. See https://www.rust-lang.org/downloads.html#win-foot for
25 | # a description of the toolchain differences.
26 | # See https://github.com/rust-lang-nursery/rustup.rs/#toolchain-specification for description of
27 | # toolchains and host triples.
28 | #
29 | # Comment out channel/target combos you do not wish to build in CI.
30 | #
31 | # You may use the `cargoflags` and `RUSTFLAGS` variables to set additional flags for cargo commands
32 | # and rustc, respectively. For instance, you can uncomment the cargoflags lines in the nightly
33 | # channels to enable unstable features when building for nightly. Or you could add additional
34 | # matrix entries to test different combinations of features.
35 | environment:
36 | matrix:
37 |
38 | ### MSVC Toolchains ###
39 |
40 | # Stable 64-bit MSVC
41 | - channel: stable
42 | target: x86_64-pc-windows-msvc
43 | # Stable 32-bit MSVC
44 | - channel: stable
45 | target: i686-pc-windows-msvc
46 | # Beta 64-bit MSVC
47 | - channel: beta
48 | target: x86_64-pc-windows-msvc
49 | # Beta 32-bit MSVC
50 | - channel: beta
51 | target: i686-pc-windows-msvc
52 | # Nightly 64-bit MSVC
53 | - channel: nightly
54 | target: x86_64-pc-windows-msvc
55 | #cargoflags: --features "unstable"
56 | # Nightly 32-bit MSVC
57 | - channel: nightly
58 | target: i686-pc-windows-msvc
59 | #cargoflags: --features "unstable"
60 |
61 | ### GNU Toolchains ###
62 |
63 | # Stable 64-bit GNU
64 | - channel: stable
65 | target: x86_64-pc-windows-gnu
66 | # Stable 32-bit GNU
67 | - channel: stable
68 | target: i686-pc-windows-gnu
69 | # Beta 64-bit GNU
70 | - channel: beta
71 | target: x86_64-pc-windows-gnu
72 | # Beta 32-bit GNU
73 | - channel: beta
74 | target: i686-pc-windows-gnu
75 | # Nightly 64-bit GNU
76 | - channel: nightly
77 | target: x86_64-pc-windows-gnu
78 | #cargoflags: --features "unstable"
79 | # Nightly 32-bit GNU
80 | - channel: nightly
81 | target: i686-pc-windows-gnu
82 | #cargoflags: --features "unstable"
83 |
84 | ### Allowed failures ###
85 |
86 | # See Appveyor documentation for specific details. In short, place any channel or targets you wish
87 | # to allow build failures on (usually nightly at least is a wise choice). This will prevent a build
88 | # or test failure in the matching channels/targets from failing the entire build.
89 | matrix:
90 | allow_failures:
91 | - channel: nightly
92 |
93 | # If you only care about stable channel build failures, uncomment the following line:
94 | #- channel: beta
95 |
96 | ## Install Script ##
97 |
98 | # This is the most important part of the Appveyor configuration. This installs the version of Rust
99 | # specified by the 'channel' and 'target' environment variables from the build matrix. This uses
100 | # rustup to install Rust.
101 | #
102 | # For simple configurations, instead of using the build matrix, you can simply set the
103 | # default-toolchain and default-host manually here.
104 | install:
105 | - appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe
106 | - rustup-init -yv --default-toolchain %channel% --default-host %target%
107 | - set PATH=%PATH%;%USERPROFILE%\.cargo\bin
108 | - rustc -vV
109 | - cargo -vV
110 |
111 | ## Build Script ##
112 |
113 | # 'cargo test' takes care of building for us, so disable Appveyor's build stage. This prevents
114 | # the "directory does not contain a project or solution file" error.
115 | build: false
116 |
117 | # Uses 'cargo test' to run tests and build. Alternatively, the project may call compiled programs
118 | #directly or perform other testing commands. Rust will automatically be placed in the PATH
119 | # environment variable.
120 | test_script:
121 | - cargo test --verbose %cargoflags%
--------------------------------------------------------------------------------
/azure-pipelines.yml:
--------------------------------------------------------------------------------
1 | strategy:
2 | matrix:
3 | windows-stable:
4 | imageName: 'vs2017-win2016'
5 | rustup_toolchain: stable
6 | mac-stable:
7 | imageName: 'macos-10.13'
8 | rustup_toolchain: stable
9 | linux-stable:
10 | imageName: 'ubuntu-16.04'
11 | rustup_toolchain: stable
12 | linux-beta:
13 | imageName: 'ubuntu-16.04'
14 | rustup_toolchain: beta
15 | linux-nightly:
16 | imageName: 'ubuntu-16.04'
17 | rustup_toolchain: nightly
18 |
19 | pool:
20 | vmImage: $(imageName)
21 |
22 | steps:
23 | - script: |
24 | curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain $RUSTUP_TOOLCHAIN
25 | echo "##vso[task.setvariable variable=PATH;]$PATH:$HOME/.cargo/bin"
26 | displayName: Install rust
27 | condition: ne( variables['Agent.OS'], 'Windows_NT' )
28 | - script: |
29 | curl -sSf -o rustup-init.exe https://win.rustup.rs
30 | rustup-init.exe -y --default-toolchain %RUSTUP_TOOLCHAIN%
31 | echo "##vso[task.setvariable variable=PATH;]%PATH%;%USERPROFILE%\.cargo\bin"
32 | displayName: Windows install rust
33 | condition: eq( variables['Agent.OS'], 'Windows_NT' )
34 | - script: cargo build --all
35 | displayName: Cargo build
36 | - script: cargo test --all
37 | displayName: Cargo test
38 | - script: rustup component add rustfmt
39 | displayName: Install Rustfmt
40 | - script: cargo fmt --all -- --check
41 | displayName: Run Rustfmt
--------------------------------------------------------------------------------
/codecov.yml:
--------------------------------------------------------------------------------
1 | codecov:
2 | notify:
3 | require_ci_to_pass: yes
4 |
5 | coverage:
6 | precision: 2
7 | round: down
8 | range: 50...100
9 |
10 | status:
11 | # Learn more at https://codecov.io/docs#yaml_default_commit_status
12 | project: true
13 | patch: true
14 | changes: false
15 |
16 | # We don't want statistics for the tests themselves and certainly not for the
17 | # benchmarks and boost libraries. Note that while we exclude the gcov data for
18 | # these patterns in the codecov call (codecov --gcov-glob ...), the fact that
19 | # our code references these areas also means we need to tell codecov itself to
20 | # ignore them from the stats.
21 | # ignore:
22 |
23 | comment:
24 | layout: "header, diff, changes, uncovered"
25 | behavior: default # update if exists else create new
--------------------------------------------------------------------------------
/medias/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/utilForever/rust-oss-template/b3250bf221761e5690f3ced8484c8e02f7a00fc0/medias/logo.png
--------------------------------------------------------------------------------
/rust_oss_template/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "rust_oss_template"
3 | version = "0.1.0"
4 | authors = ["Chris Ohk "]
5 | edition = "2018"
6 |
7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
8 |
9 | [dependencies]
10 |
--------------------------------------------------------------------------------
/rust_oss_template/src/lib.rs:
--------------------------------------------------------------------------------
1 | pub fn add(x: i32, y: i32) -> i32 {
2 | x + y
3 | }
4 |
5 | #[cfg(test)]
6 | mod tests {
7 | use super::*;
8 |
9 | #[test]
10 | fn test_add() {
11 | assert_eq!(add(3, 4), 7);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------