Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: CI changes #25

Merged
merged 6 commits into from
Feb 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
changelog:
categories:
- title: 🐛 Bug fixes
labels:
- 'type: bug'
- title: 📦 Chore
labels:
- 'type: chore'
- title: 🧑‍💻 Code refactor
labels:
- 'type: refactor'
- title: 🔁 Continuous Integration
labels:
- 'type: CI'
- title: 📝 Documentation
labels:
- 'type: docs'
- title: 🏕 Features
labels:
- 'type: feature'
- title: 🔥 Performance improvements
labels:
- 'type: performance'
- title: ✅ Test
labels:
- 'type: test'
101 changes: 97 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,19 @@ name: CI
permissions:
contents: read

on: [pull_request, push]
on:
pull_request:
push:
branches:
- master

env:
CARGO_TERM_COLOR: always
CLICOLOR: 1

jobs:
check:
name: Check
name: cargo check
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
Expand Down Expand Up @@ -46,7 +54,7 @@ jobs:
run: cargo check

fmt:
name: Check style
name: cargo fmt
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
Expand All @@ -67,7 +75,7 @@ jobs:
run: cargo fmt -- --check

clippy:
name: Clippy
name: cargo clippy
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
Expand Down Expand Up @@ -106,3 +114,88 @@ jobs:

- name: cargo clippy --all-features -- -D warnings
run: cargo clippy --all-features -- -D warnings

test:
name: cargo test
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.RMAN_SCHEMA_PAT }}
submodules: true

- name: Install rust
uses: dtolnay/rust-toolchain@stable

- uses: Swatinem/rust-cache@v2

- name: Try getting flatc from cache
uses: actions/cache@v3
id: cache-flatc
with:
path: ~/.local/bin
key: ${{ runner.os }}-build-flatc-clang12-23-1-21

- name: Fetch latest flatc release
if: steps.cache-flatc.outputs.cache-hit != 'true'
uses: dsaltares/fetch-gh-release-asset@master
with:
repo: google/flatbuffers
version: tags/v23.1.21
file: Linux.flatc.binary.clang++-12.zip
target: flatc/flatc-zipped.zip

- name: Unzip fetched release
if: steps.cache-flatc.outputs.cache-hit != 'true'
run: unzip flatc/flatc-zipped.zip -d ~/.local/bin

- name: cargo test
run: cargo test

- name: cargo test --all-features
run: cargo test --all-features

doc:
name: cargo doc
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.RMAN_SCHEMA_PAT }}
submodules: true

- name: Install rust
uses: dtolnay/rust-toolchain@stable
with:
components: rust-docs

- uses: Swatinem/rust-cache@v2

- name: Try getting flatc from cache
uses: actions/cache@v3
id: cache-flatc
with:
path: ~/.local/bin
key: ${{ runner.os }}-build-flatc-clang12-23-1-21

- name: Fetch latest flatc release
if: steps.cache-flatc.outputs.cache-hit != 'true'
uses: dsaltares/fetch-gh-release-asset@master
with:
repo: google/flatbuffers
version: tags/v23.1.21
file: Linux.flatc.binary.clang++-12.zip
target: flatc/flatc-zipped.zip

- name: Unzip fetched release
if: steps.cache-flatc.outputs.cache-hit != 'true'
run: unzip flatc/flatc-zipped.zip -d ~/.local/bin

- name: cargo doc --no-deps
run: cargo doc --no-deps
env:
RUSTDOCFLAGS: -D warnings
52 changes: 52 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: CI

permissions:
contents: read

on:
release:
types: [published]

env:
CARGO_TERM_COLOR: always
CLICOLOR: 1

check:
name: cargo publish
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.RMAN_SCHEMA_PAT }}
submodules: true

- name: Install rust
uses: dtolnay/rust-toolchain@stable

- uses: Swatinem/rust-cache@v2

- name: Try getting flatc from cache
uses: actions/cache@v3
id: cache-flatc
with:
path: ~/.local/bin
key: ${{ runner.os }}-build-flatc-clang12-23-1-21

- name: Fetch latest flatc release
if: steps.cache-flatc.outputs.cache-hit != 'true'
uses: dsaltares/fetch-gh-release-asset@master
with:
repo: google/flatbuffers
version: tags/v23.1.21
file: Linux.flatc.binary.clang++-12.zip
target: flatc/flatc-zipped.zip

- name: Unzip fetched release
if: steps.cache-flatc.outputs.cache-hit != 'true'
run: unzip flatc/flatc-zipped.zip -d ~/.local/bin

- name: cargo publish
shell: bash
run: cargo publish --token ${{ secrets.CRATES_TOKEN }}
38 changes: 3 additions & 35 deletions tests/test.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use rman::{Header, RiotManifest};
use rman::RiotManifest;

mod common;

Expand All @@ -24,23 +24,7 @@ pub fn should_have_correct_values_when_valid_manifest() {
path.set_extension("manifest");
let manifest = RiotManifest::from_path(path).unwrap();

// FIXME: don't check for equality on compressed size and uncompressed size
// compressed and uncompressed size could change in the future
let header = Header {
magic: 0x4E414D52,
major: 2,
minor: 0,
flags: 512,
offset: 28,
compressed_size: 189,
manifest_id: 0,
uncompressed_size: 376,
};

assert_eq!(
&manifest.header, &header,
"manifest header should be the same"
);
// TODO: header value comparsion should also be done
assert_eq!(
manifest.data.bundle_entries.len(),
1,
Expand Down Expand Up @@ -101,23 +85,7 @@ pub fn should_have_correct_values_when_valid_empty_manifest() {
path.set_extension("manifest");
let manifest = RiotManifest::from_path(path).unwrap();

// FIXME: don't check for equality on compressed size and uncompressed size
// compressed and uncompressed size could change in the future
let header = Header {
magic: 0x4E414D52,
major: 2,
minor: 0,
flags: 512,
offset: 28,
compressed_size: 59,
manifest_id: 0,
uncompressed_size: 72,
};

assert_eq!(
&manifest.header, &header,
"manifest header should be the same"
);
// TODO: header value comparsion should also be done
assert_eq!(
manifest.data.bundle_entries.len(),
0,
Expand Down