Skip to content

Commit

Permalink
Merge pull request #6 from sebastienrousseau/feature/mini-functions
Browse files Browse the repository at this point in the history
fix(workflow) Added on: [push, pull_request]
  • Loading branch information
sebastienrousseau authored Dec 31, 2022
2 parents a981821 + 9dda39a commit 4219284
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 92 deletions.
22 changes: 3 additions & 19 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,6 @@
name: ❯ build

on:
push:
branches:
- main
paths:
- "Cargo.lock"
- "Cargo.toml"
- "src/**"
- "tests/**"
pull_request:
branches:
- main
paths:
- "Cargo.lock"
- "Cargo.toml"
- "src/**"
- "tests/**"
on: [push, pull_request]

jobs:
build-and-test:
Expand Down Expand Up @@ -79,11 +63,11 @@ jobs:
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Build default target in debug mode
run: cargo build --target ${{ matrix.target }} --locked
run: cargo build --target ${{ matrix.target }}

- name: Build Apple ARM64 target in debug mode
if: ${{ matrix.os == 'macos-latest' }}
run: cargo build --target ${{ matrix.target2 }} --locked
run: cargo build --target ${{ matrix.target2 }}

- name: Test default target in debug mode
run: cargo test --target ${{ matrix.target }}
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/fmt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: ❯ rustfmt

on: [push, pull_request]

env:
CARGO_TERM_COLOR: always

jobs:
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all --check --verbose
88 changes: 80 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,84 @@
name: ❯ release

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

env:
APP_NAME: "mini-functions"
RUSTFLAGS: -D warnings
RUSTDOCFLAGS: -D warnings
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target/release
key: release-${{ runner.os }}-${{ github.job }}-${{ secrets.CI_CACHE_VERSION }}
- run: cargo test --release

publish-binary:
needs:
- verify-version
- test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
include:
- os: macos-latest
artifact_prefix: macos-x86-64
target: x86_64-apple-darwin
- os: ubuntu-latest
artifact_prefix: linux-x86-64
target: x86_64-unknown-linux-gnu
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target/release
key: release-${{ runner.os }}-${{ github.job }}-${{ secrets.CI_CACHE_VERSION }}
- run: cargo build --release --target ${{ matrix.target }}
- name: package binary
shell: bash
run: |
cd target/${{ matrix.target }}/release
strip ${{ github.event.repository.name }}
tar czvf \
${{ github.event.repository.name }}-${{ matrix.artifact_prefix }}.tar.gz \
${{ github.event.repository.name }}
shasum -a 256 ${{ github.event.repository.name }}-${{ matrix.artifact_prefix }}.tar.gz \
> ${{ github.event.repository.name }}-${{ matrix.artifact_prefix }}.sha256
- name: publish release to github
uses: softprops/action-gh-release@v1
with:
files: |
target/${{ matrix.target }}/release/${{ github.event.repository.name }}-${{ matrix.artifact_prefix }}.tar.gz
target/${{ matrix.target }}/release/${{ github.event.repository.name }}-${{ matrix.artifact_prefix }}.sha256
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

publish-crate:
needs:
- verify-version
- test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target/release
key: release-${{ runner.os }}-${{ github.job }}-${{ secrets.CI_CACHE_VERSION }}
- run: cargo publish --token ${{ secrets.CARGO_API_TOKEN }} --allow-dirty
60 changes: 10 additions & 50 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -1,60 +1,20 @@
name: ❯ rust

on: [push, pull_request]

env:
APP_NAME: "mini-functions"
CARGO_TERM_COLOR: always

on:
push:
paths-ignore:
- "**.md"
branches:
- master

jobs:
build:
runs-on: ubuntu-18.04
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2

- name: Cache Packages
uses: Swatinem/rust-cache@v1.0.1

- uses: actions/checkout@v3
- name: Build
run: cargo build --release

- name: Publish to crates.io
continue-on-error: true
run: cargo publish --no-verify --token ${{ secrets.CARGO_REGISTRY_TOKEN }}

- uses: actions/upload-artifact@v2.2.1
name: Upload a Build Artifact
with:
name: ${{ env.APP_NAME }}
path: target/release/${{ env.APP_NAME }}

- name: Versions
id: version
run: |
echo "::set-output name=version::$(cargo metadata --format-version 1 --no-deps | jq .packages[0].version -r | sed 's/^/v/')"
echo "::set-output name=tag::$(git describe --tags)"
- name: Calculate SHA512 checksum
run: sha512sum target/release/${{ env.APP_NAME }} > ${{ env.APP_NAME }}.sha512

- name: Release
uses: softprops/action-gh-release@v1
if: github.base_ref != 'master'
with:
tag_name: ${{ steps.version.outputs.version }}
name: ${{ steps.version.outputs.version }} - ${{ github.event.head_commit.message }}
draft: true
files: |
target/release/${{ env.APP_NAME }}
${{ env.APP_NAME }}.sha512
body: |
- ${{ github.event.head_commit.message }} ${{ github.sha }}
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
11 changes: 3 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,21 @@ include = [
"/LICENSE-Apache",
"/LICENSE-MIT",
"/README.md",
"/src/**"
"/src/**",
"/tests/**",
]
keywords = ["functions"]
license = "Apache-2.0 OR MIT"
name = "mini-functions"
readme = "README.md"
repository = "https://github.com/sebastienrousseau/mini-functions.git"
resolver = "2" # Enables the new Cargo resolution engine
rust-version = "1.57.0"
version = "0.0.1"

[badges]
maintenance = { status = "actively-developed" }

[lib]
bench = false

[[test]]
name = "tests"
path = "./tests/main.rs"

[dependencies]
time = { version ="0.3.17", features = ["default"] }

Expand Down
4 changes: 2 additions & 2 deletions src/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ impl Date {
}
/// Get the weekday of the date in the stored offset.
///
/// This current uses Zeller's congruence internally.
/// This current uses Zellers congruence internally.
pub fn weekday() -> String {
OffsetDateTime::now_utc().weekday().to_string()
}
}
}
7 changes: 2 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
//! <https://minifunctions.com>
#![doc(
html_logo_url = "https://raw.githubusercontent.com/sebastienrousseau/vault/main/assets/icons/ico-mini-functions.svg",
html_root_url = "https://docs.rs/mini-functions/0.0.1"
html_logo_url = "https://raw.githubusercontent.com/sebastienrousseau/vault/main/assets/icons/ico-mini-functions.svg"
)]
#![forbid(unsafe_code)]
#![warn(missing_docs, rust_2018_idioms, trivial_casts, unused_qualifications)]
pub mod date;
pub mod date;

0 comments on commit 4219284

Please sign in to comment.