Skip to content

Commit 7c38a17

Browse files
committed
ci: Update rust example
0 parents  commit 7c38a17

35 files changed

+1245
-0
lines changed

.dockerignore

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# all start with .(dot), including directories and files
2+
.*
3+
CHANGELOG.md
4+
CODE_OF_CONDUCT.md
5+
compose.yml
6+
CONTRIBUTING.md
7+
Dockerfile
8+
LICENSE*
9+
README.md
10+
SECURITY.md

.editorconfig

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_size = 4
7+
indent_style = space
8+
insert_final_newline = true
9+
max_line_length = 120
10+
tab_width = 4
11+
trim_trailing_whitespace = true
12+
13+
[Makefile]
14+
indent_style = tab

.github/ISSUE_TEMPLATE/bug_report.md

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: 'bug: '
5+
labels: bug
6+
assignees: ''
7+
8+
---
9+
10+
## Bug description
11+
12+
<!-- A clear and concise description of what the bug is. -->
13+
14+
- Would you like to work on a fix? [y/n]
15+
16+
## To Reproduce
17+
18+
Steps to reproduce the behavior:
19+
20+
1. ...
21+
2. ...
22+
3. ...
23+
4. ...
24+
25+
<!-- Make sure you are able to reproduce the bug in the main branch, too. -->
26+
27+
## Expected behavior
28+
29+
<!-- A clear and concise description of what you expected to happen. -->
30+
31+
## Screenshots
32+
33+
<!-- If applicable, add screenshots to help explain your problem. -->
34+
35+
## Environment
36+
37+
<!-- Please fill the following information. -->
38+
39+
- OS: [e.g. Ubuntu 20.04]
40+
- example_rs version: [e.g. 0.1.0]
41+
42+
## Additional context
43+
44+
<!-- Add any other context about the problem here. -->

.github/ISSUE_TEMPLATE/config.yml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
blank_issues_enabled: true
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: 'Feature Request: '
5+
labels: enhancement
6+
assignees: ''
7+
8+
---
9+
10+
## Motivations
11+
12+
<!--
13+
If your feature request is related to a problem, please describe it.
14+
-->
15+
16+
- Would you like to implement this feature? [y/n]
17+
18+
## Solution
19+
20+
<!-- Describe the solution you'd like. -->
21+
22+
## Alternatives
23+
24+
<!-- Describe any alternative solutions or features you've considered. -->
25+
26+
## Additional context
27+
28+
<!-- Add any other context or screenshots about the feature request here. -->

.github/PULL_REQUEST_TEMPLATE.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!-- Please explain the changes you made -->
2+
3+
<!--
4+
Please make sure:
5+
- you have read the contributing guidelines:
6+
https://github.com/x-pt/example-rs/blob/main/docs/CONTRIBUTING.md
7+
- you have updated the changelog (if needed):
8+
https://github.com/x-pt/example-rs/blob/main/CHANGELOG.md
9+
-->

.github/configs/labeler.yml

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
version: 1
2+
3+
labels:
4+
# Type: Build-related changes
5+
- label: "@type/build"
6+
title: '^build(?:\(.+\))?\!?:'
7+
8+
# Type: CI-related changes
9+
- label: "@type/ci"
10+
title: '^ci(?:\(.+\))?\!?:'
11+
files:
12+
- '\.github/.+'
13+
14+
# Type: Documentation changes
15+
- label: "@type/docs"
16+
title: '^docs(?:\(.+\))?\!?:'
17+
files:
18+
- "docs/.+"
19+
- "**/*.md"
20+
21+
# Type: New feature
22+
- label: "@type/feature"
23+
title: '^feat(?:\(.+\))?\!?:'
24+
25+
# Type: Bug fix
26+
- label: "@type/fix"
27+
title: '^fix(?:\(.+\))?\!?:'
28+
29+
# Type: Improvements such as style changes, refactoring, or performance improvements
30+
- label: "@type/improve"
31+
title: '^(style|refactor|perf)(?:\(.+\))?\!?:'
32+
33+
# Type: Dependency changes
34+
- label: "@type/dependency"
35+
title: '^(chore|build)(?:\(deps\))?\!?:'
36+
37+
# Type: Test-related changes
38+
- label: "@type/test"
39+
title: '^test(?:\(.+\))?\!?:'
40+
files:
41+
- "tests/.+"
42+
- "spec/.+"
43+
44+
# Type: Security-related changes
45+
- label: "@type/security"
46+
title: '^security(?:\(.+\))?\!?:'
47+
files:
48+
- "**/security/.+"
49+
50+
# Issue Type Only: Feature Request
51+
- label: "Feature Request"
52+
type: issue
53+
title: "^Feature Request:"
54+
55+
# Issue Type Only: Documentation
56+
- label: "Documentation"
57+
type: issue
58+
title: "^.*(\b[Dd]ocumentation|doc(s)?\b).*"
59+
60+
# Issue Type Only: Bug Report
61+
- label: "Bug Report"
62+
type: issue
63+
title: "^.*(\b[Bb]ug|b(u)?g(s)?\b).*"

.github/dependabot.yml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
# Check for updates every Monday
6+
schedule:
7+
interval: "weekly"
8+
open-pull-requests-limit: 10

.github/renovate.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3+
"extends": [
4+
"config:base"
5+
]
6+
}

.github/workflows/cd.yml

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: CD # Continuous Deployment
2+
3+
on:
4+
push:
5+
tags:
6+
- '[v]?[0-9]+.[0-9]+.[0-9]+'
7+
8+
jobs:
9+
publish:
10+
name: Publishing for ${{ matrix.job.os }}
11+
runs-on: ${{ matrix.job.os }}
12+
strategy:
13+
matrix:
14+
rust: [ stable ]
15+
job:
16+
- { os: macos-latest, target: x86_64-apple-darwin, architecture: x86_64, binary-postfix: "", use-cross: false }
17+
- { os: macos-latest, target: aarch64-apple-darwin, architecture: arm64, binary-postfix: "", use-cross: false }
18+
- { os: ubuntu-latest, target: x86_64-unknown-linux-gnu, architecture: x86_64, binary-postfix: "", use-cross: false }
19+
- { os: windows-latest, target: x86_64-pc-windows-msvc, architecture: x86_64, binary-postfix: ".exe", use-cross: false }
20+
- { os: ubuntu-latest, target: aarch64-unknown-linux-gnu, architecture: arm64, binary-postfix: "", use-cross: true }
21+
- { os: ubuntu-latest, target: i686-unknown-linux-gnu, architecture: i686, binary-postfix: "", use-cross: true }
22+
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v4
26+
27+
- name: Install Rust toolchain
28+
uses: actions-rs/toolchain@v1
29+
with:
30+
toolchain: ${{ matrix.rust }}
31+
target: ${{ matrix.job.target }}
32+
profile: minimal
33+
override: true
34+
35+
- uses: Swatinem/rust-cache@v2
36+
37+
- name: Build Cargo package
38+
uses: actions-rs/cargo@v1
39+
with:
40+
command: build
41+
use-cross: ${{ matrix.job.use-cross }}
42+
toolchain: ${{ matrix.rust }}
43+
args: --release --target ${{ matrix.job.target }}
44+
45+
- name: Install strip command (if needed)
46+
if: startsWith(matrix.job.target, 'aarch64')
47+
run: sudo apt-get install -y binutils-aarch64-linux-gnu
48+
49+
- name: Package final binary
50+
run: |
51+
cd target/${{ matrix.job.target }}/release
52+
BINARY_NAME=example-rs${{ matrix.job.binary-postfix }}
53+
GCC_PREFIX=$( [ "${{ matrix.job.target }}" == "aarch64-unknown-linux-gnu" ] && echo "aarch64-linux-gnu-" || echo "" )
54+
"$GCC_PREFIX"strip $BINARY_NAME
55+
56+
RELEASE_NAME=example-rs-${GITHUB_REF/refs\/tags\//}-${{ matrix.job.os-name }}-${{ matrix.job.architecture }}
57+
tar czvf $RELEASE_NAME.tar.gz $BINARY_NAME
58+
shasum -a 256 $RELEASE_NAME.tar.gz > $RELEASE_NAME.sha256
59+
60+
- name: Release assets
61+
uses: softprops/action-gh-release@v2
62+
with:
63+
files: |
64+
target/${{ matrix.job.target }}/release/example-rs-*.tar.gz
65+
target/${{ matrix.job.target }}/release/example-rs-*.sha256
66+
env:
67+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
68+
publish-cargo:
69+
name: Publishing to Cargo
70+
runs-on: ubuntu-latest
71+
steps:
72+
- name: Checkout repository
73+
uses: actions/checkout@v4
74+
75+
- name: Install Rust toolchain
76+
uses: dtolnay/rust-toolchain@stable
77+
78+
- uses: Swatinem/rust-cache@v2
79+
80+
- run: cargo publish
81+
env:
82+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

.github/workflows/ci.yml

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: CI # Continuous Integration
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
workflow_dispatch:
9+
10+
jobs:
11+
lint:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Install Rust toolchain
17+
uses: dtolnay/rust-toolchain@stable
18+
with:
19+
components: rustfmt, clippy
20+
21+
- name: Cache Rust dependencies
22+
uses: Swatinem/rust-cache@v2
23+
24+
- name: Check formatting
25+
run: cargo fmt --all --check
26+
27+
- name: Clippy check
28+
run: cargo clippy --all-targets --all-features --workspace -- -D warnings
29+
30+
- name: Check documentation
31+
env:
32+
RUSTDOCFLAGS: -D warnings
33+
run: cargo doc --no-deps --document-private-items --all-features --workspace --examples
34+
35+
test:
36+
runs-on: ${{ matrix.os }}
37+
strategy:
38+
matrix:
39+
os: [ ubuntu-latest, windows-latest, macos-latest ]
40+
41+
steps:
42+
- uses: actions/checkout@v4
43+
44+
- name: Install Rust toolchain
45+
uses: dtolnay/rust-toolchain@stable
46+
47+
- name: Cache Rust dependencies
48+
uses: Swatinem/rust-cache@v2
49+
50+
- name: Run tests
51+
run: cargo test --all-features --workspace

.github/workflows/docker.yml

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Build and Push Docker Image
2+
3+
on:
4+
push:
5+
tags:
6+
- '^v[0-9]+\.[0-9]+\.[0-9]+.*$'
7+
8+
jobs:
9+
docker:
10+
runs-on: ubuntu-latest
11+
steps:
12+
-
13+
name: Checkout
14+
uses: actions/checkout@v4
15+
-
16+
name: Acquire tag name
17+
run: echo "RELEASE_VERSION=${GITHUB_REF_NAME#refs/*/}" >> $GITHUB_ENV
18+
-
19+
name: Set up QEMU
20+
uses: docker/setup-qemu-action@v3
21+
-
22+
name: Set up Docker Buildx
23+
uses: docker/setup-buildx-action@v3
24+
-
25+
name: Login to GitHub Container Registry
26+
uses: docker/login-action@v3
27+
with:
28+
registry: ghcr.io
29+
username: ${{ github.repository_owner }}
30+
password: ${{ secrets.GITHUB_TOKEN }}
31+
-
32+
name: Build and Export to Docker
33+
uses: docker/build-push-action@v6
34+
with:
35+
context: .
36+
load: true
37+
tags: |
38+
ghcr.io/x-pt/example-rs:latest
39+
ghcr.io/x-pt/example-rs:${GITHUB_REF_NAME:1}
40+
-
41+
name: Test it before Push
42+
run: |
43+
docker run --rm ghcr.io/x-pt/example-rs:latest
44+
docker run --rm ghcr.io/x-pt/example-rs:${GITHUB_REF_NAME:1}
45+
-
46+
name: Build and Push
47+
uses: docker/build-push-action@v6
48+
with:
49+
context: .
50+
platforms: linux/amd64,linux/arm64
51+
push: true
52+
tags: |
53+
ghcr.io/x-pt/example-rs:latest
54+
ghcr.io/x-pt/example-rs:${GITHUB_REF_NAME:1}

.github/workflows/labeler.yml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Labeler
2+
3+
on:
4+
- pull_request
5+
- issues
6+
7+
jobs:
8+
labeler:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: srvaroa/labeler@master
12+
with:
13+
config_path: .github/configs/labeler.yml
14+
env:
15+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)