Skip to content

Commit 5e1db23

Browse files
committed
CI workflows
1 parent 695e212 commit 5e1db23

11 files changed

Lines changed: 384 additions & 16 deletions

File tree

.cargo/config

Whitespace-only changes.

.editorconfig

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
# top-most EditorConfig file
44
root = true
55

6+
[*.{rs}]
7+
indent_size = 4
8+
69
[*]
710
indent_style = space
8-
indent_size = 4
11+
indent_size = 2
912
end_of_line = lf
1013
charset = utf-8
1114
trim_trailing_whitespace = true

.github/workflows/build.yml

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: Build
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
extended_targets:
6+
description: Build extended targets
7+
type: boolean
8+
required: false
9+
default: false
10+
workflow_call:
11+
inputs:
12+
extended_targets:
13+
description: Build extended targets
14+
type: boolean
15+
required: false
16+
default: false
17+
18+
push:
19+
branches:
20+
- main
21+
# - dev
22+
jobs:
23+
# docs:
24+
# name: Documentation
25+
# runs-on: ubuntu-latest
26+
# steps:
27+
# - name: Checkout repository
28+
# uses: actions/checkout@v2
29+
# - name: Install Rust
30+
# uses: actions-rs/toolchain@v1
31+
# with:
32+
# toolchain: stable
33+
# override: true
34+
# profile: minimal
35+
# components: rustfmt
36+
# - name: Check documentation
37+
# env:
38+
# RUSTDOCFLAGS: -D warnings
39+
# run: cargo doc --no-deps --document-private-items --workspace
40+
41+
build:
42+
name: Build - ${{ matrix.rust }} - ${{ matrix.os }}
43+
runs-on: ${{ matrix.os }}
44+
strategy:
45+
fail-fast: false
46+
matrix:
47+
include:
48+
- {
49+
rust: stable,
50+
os: macos-latest,
51+
artifact_name: santa,
52+
asset_name: santa-macos,
53+
}
54+
- {
55+
rust: stable,
56+
os: ubuntu-latest,
57+
artifact_name: santa,
58+
asset_name: santa-linux,
59+
}
60+
- {
61+
rust: stable,
62+
os: windows-latest,
63+
artifact_name: santa.exe,
64+
asset_name: santa-windows.exe,
65+
}
66+
# - { rust: stable-x86_64-gnu, os: windows-latest }
67+
# - { rust: stable-i686-msvc, os: windows-latest }
68+
# - { rust: stable-i686-gnu, os: windows-latest }
69+
steps:
70+
- uses: actions/checkout@v2
71+
- name: Install Rust
72+
uses: actions-rs/toolchain@v1
73+
with:
74+
toolchain: ${{ matrix.rust }}
75+
override: true
76+
profile: minimal
77+
- uses: actions-rs/cargo@v1
78+
with:
79+
command: build
80+
args: --release --all-features
81+
- uses: actions/upload-artifact@v3
82+
with:
83+
name: ${{ matrix.asset_name }}
84+
path: target/release/${{ matrix.artifact_name }}
85+
86+
build-cross:
87+
name: Build - ${{ matrix.target }} - cross
88+
runs-on: ubuntu-latest
89+
if: github.event.inputs.extended_targets == true
90+
strategy:
91+
fail-fast: false
92+
matrix:
93+
target:
94+
# 32-bit x86
95+
- i686-unknown-linux-gnu
96+
# 32-bit ARM (on Android)
97+
- armv7-linux-androideabi
98+
# 64-bit ARM (on Android)
99+
- aarch64-linux-android
100+
include:
101+
- { asset_name: santa }
102+
103+
steps:
104+
- uses: actions/checkout@v2
105+
- name: Install Rust
106+
uses: actions-rs/toolchain@v1
107+
with:
108+
toolchain: stable
109+
override: true
110+
profile: minimal
111+
target: ${{ matrix.target }}
112+
- uses: actions-rs/cargo@v1
113+
with:
114+
command: build
115+
args: --release --target=${{ matrix.target }} --all-features
116+
use-cross: true
117+
- uses: actions/upload-artifact@v3
118+
with:
119+
name: ${{ matrix.asset_name }}-${{ matrix.target }}
120+
path: target/${{ matrix.target }}/release/${{ matrix.asset_name }}

.github/workflows/pr.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: PR Validation
2+
on:
3+
workflow_dispatch:
4+
pull_request:
5+
branches: [main]
6+
push:
7+
branches: [dev]
8+
jobs:
9+
rustfmt:
10+
name: Formatting
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v2
15+
- name: Install Rust
16+
uses: actions-rs/toolchain@v1
17+
with:
18+
toolchain: stable
19+
profile: minimal
20+
components: rustfmt
21+
- name: Check formatting
22+
run: |
23+
cargo fmt --all -- --check
24+
25+
lint:
26+
name: clippy (lint)
27+
runs-on: ubuntu-latest
28+
if: ${{ !env.ACT }}
29+
steps:
30+
- uses: actions/checkout@v2
31+
- name: Install Rust
32+
uses: actions-rs/toolchain@v1
33+
with:
34+
toolchain: stable
35+
profile: minimal
36+
- name: Annotate commit with clippy warnings
37+
uses: actions-rs/clippy-check@v1
38+
with:
39+
token: ${{ secrets.GITHUB_TOKEN }}
40+
args: --all-features
41+
42+
build-pr:
43+
name: Build
44+
runs-on: ubuntu-latest
45+
needs: [rustfmt]
46+
steps:
47+
- uses: actions/checkout@v2
48+
- name: Install Rust
49+
uses: actions-rs/toolchain@v1
50+
with:
51+
toolchain: stable
52+
profile: minimal
53+
- uses: actions-rs/cargo@v1
54+
with:
55+
command: build
56+
args: --release --all-features
57+
# test:
58+
# name: Test
59+
# runs-on: ubuntu-latest
60+
# steps:
61+
# - uses: actions/checkout@v2
62+
# - name: Install Rust
63+
# uses: actions-rs/toolchain@v1
64+
# with:
65+
# toolchain: stable
66+
# override: true
67+
# profile: minimal
68+
# - uses: actions-rs/cargo@v1
69+
# with:
70+
# command: test
71+
# args: --verbose --all-features

.github/workflows/release.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Release
2+
on:
3+
push:
4+
tags:
5+
- 'v[0-9]+.*'
6+
workflow_dispatch:
7+
inputs:
8+
version:
9+
description: 'Release version'
10+
required: true
11+
default: ''
12+
type: string
13+
commit:
14+
description: 'Commit to release'
15+
required: true
16+
type: string
17+
draft:
18+
description: 'Draft'
19+
required: false
20+
type: boolean
21+
default: true
22+
jobs:
23+
build-release:
24+
name: build-release
25+
uses: ./.github/workflows/build.yml
26+
27+
create-release:
28+
name: Create release
29+
runs-on: ubuntu-latest
30+
# Note this. We are going to use that in further jobs.
31+
# outputs:
32+
# upload_url: ${{ steps.create_release.outputs.upload_url }}
33+
needs: ['build-release']
34+
env:
35+
APP_VERSION: ${{ github.event.inputs.version }}
36+
steps:
37+
- uses: actions/download-artifact@v3
38+
with:
39+
path: artifacts
40+
41+
- name: Display structure of downloaded files
42+
run: ls -R
43+
working-directory: artifacts
44+
45+
- name: Get the release version from the tag
46+
shell: bash
47+
if: env.APP_VERSION == ''
48+
run: |
49+
# Apparently, this is the right way to get a tag name. Really?
50+
#
51+
# See: https://github.community/t5/GitHub-Actions/How-to-get-just-the-tag-name/m-p/32167/highlight/true#M1027
52+
echo "APP_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
53+
- name: Output the version
54+
shell: bash
55+
run: |
56+
echo "version is: ${{ env.APP_VERSION }}"
57+
- name: Create release
58+
id: create_release
59+
uses: softprops/action-gh-release@v1
60+
if: startsWith(github.ref, 'refs/tags/')
61+
with:
62+
draft: ${{ github.event.inputs.draft }}
63+
files: |
64+
artifacts/**

.github/workflows/test.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Test
2+
on:
3+
workflow_dispatch:
4+
# push:
5+
# branches:
6+
# - main
7+
# - dev
8+
jobs:
9+
test-mac-win:
10+
name: Test Rust ${{ matrix.rust }} on ${{ matrix.os }}
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
include:
16+
- { rust: stable, os: macos-latest }
17+
- { rust: stable, os: windows-latest }
18+
# Note: If you don't know if you want to be
19+
# testing on these configurations, you probably
20+
# don't need to include these lines.
21+
- { rust: stable-x86_64-gnu, os: windows-latest }
22+
- { rust: stable-i686-msvc, os: windows-latest }
23+
- { rust: stable-i686-gnu, os: windows-latest }
24+
steps:
25+
- uses: actions/checkout@v2
26+
- uses: hecrj/setup-rust-action@v1
27+
with:
28+
rust-version: ${{ matrix.rust }}
29+
- run: cargo test --verbose --workspace --all-features
30+
- run: cargo test --verbose --workspace --no-default-features
31+
32+
cross-test:
33+
name: Test on ${{ matrix.target }} (using cross)
34+
runs-on: ubuntu-latest
35+
strategy:
36+
fail-fast: false
37+
matrix:
38+
target:
39+
# 32-bit x86
40+
- i686-unknown-linux-gnu
41+
# 32-bit ARM (on Android)
42+
- armv7-linux-androideabi
43+
# 64-bit ARM (on Android)
44+
- aarch64-linux-android
45+
# 32-bit MIPS(-BE) (that is: big endian)
46+
- mips-unknown-linux-gnu
47+
# 64-bit MIPS(-BE) (that is: big endian)
48+
- mips64-unknown-linux-gnuabi64
49+
# Tons of others...
50+
steps:
51+
- uses: actions/checkout@v2
52+
- uses: hecrj/setup-rust-action@v1.3.4
53+
- run: cargo install cross
54+
# Note: just use `cross` as you would `cargo`, but always
55+
# pass the `--target=${{ matrix.target }}` arg. (Yes, really).
56+
- run: cross test --verbose --target=${{ matrix.target }} --no-default-features
57+
- run: cross test --verbose --target=${{ matrix.target }} --all-features
58+
# ...
59+
60+
checks:
61+
name: Checks
62+
runs-on: ubuntu-latest
63+
steps:
64+
- name: Checkout repository
65+
uses: actions/checkout@v2
66+
- name: Install Rust
67+
uses: actions-rs/toolchain@v1
68+
with:
69+
toolchain: stable
70+
override: true
71+
profile: minimal
72+
components: rustfmt
73+
- name: Check formatting
74+
run: |
75+
cargo fmt --all -- --check
76+
- name: Check documentation
77+
env:
78+
RUSTDOCFLAGS: -D warnings
79+
run: cargo doc --no-deps --document-private-items --workspace

.vscode/settings.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
11
{
2-
"workbench.colorTheme": "One Dark Pro"
3-
}
2+
"workbench.colorTheme": "One Dark Pro",
3+
"yaml.schemas": {
4+
"https://json.schemastore.org/github-workflow.json": "file:///c%3A/code/santa/.github/workflows/build.yaml"
5+
},
6+
"files.eol": "\n",
7+
"files.trimFinalNewlines": true,
8+
"files.insertFinalNewline": true,
9+
"files.trimTrailingWhitespace": true
10+
}

Cross.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# [build.env]
2+
# volumes = ["BUILD_DIR"]
3+
# passthrough = ["IMPORTANT_ENV_VARIABLES"]

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,25 @@ packages:
4848
- [ ] Centralize the logic for loading the right `PackageData` for a given package taking into account the elf that the
4949
package is configured to use. There should be a single place that answers the question, "is this package enabled?"
5050
That should be the Config. App should load data, use it to initialize config (i.e. merge the two)
51+
52+
## Commands
53+
54+
### Build:
55+
56+
```
57+
cargo build [--release]
58+
```
59+
60+
### Check for unused dependencies
61+
62+
First, install [cargo-udeps](https://github.com/est31/cargo-udeps):
63+
64+
```
65+
cargo install cargo-udeps --locked
66+
```
67+
68+
Then run it:
69+
70+
```
71+
cargo +nightly udeps
72+
```

0 commit comments

Comments
 (0)