Skip to content

Commit

Permalink
clean up github workflows ui
Browse files Browse the repository at this point in the history
This puts different kinds of tests in different job names, instead of
shoehorning them into the matrix.
  • Loading branch information
quodlibetor committed Jun 27, 2020
1 parent 43db62e commit c2fe38c
Show file tree
Hide file tree
Showing 7 changed files with 139 additions and 64 deletions.
94 changes: 64 additions & 30 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test
name: test

on:
push:
Expand All @@ -12,20 +12,17 @@ jobs:
matrix:
os: [ubuntu-16.04, ubuntu-latest, macos-latest, windows-latest]
rust_version: [stable]
wasm: ['no_wasm']
core: ['std']
kind: ['test']
include:
# check all tzs on most-recent OS's
- os: ubuntu-latest
rust_version: stable
kind: lint
# check all tzs occasionally
- os: ubuntu-latest
rust_version: stable
exhaustive_tz: y
exhaustive_tz: all_tzs
- os: windows-latest
rust_version: stable
exhaustive_tz: y
exhaustive_tz: all_tzs
- os: macos-latest
rust_version: stable
exhaustive_tz: all_tzs
# test other rust versions
- os: ubuntu-latest
rust_version: beta
Expand All @@ -36,49 +33,86 @@ jobs:
- os: macos-latest
rust_version: 1.13.0
# time doesn't work on windows with 1.13
# test wasmbind
- os: macos-latest
wasm: 'yes_wasm'
rust_version: stable
# test no_std
- os: macos-latest
core: 'no_std'
rust_version: stable
- os: ubuntu-latest
core: 'no_std'
rust_version: stable

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2

- name: Install rust
if: ${{ matrix.core == 'std' }}
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust_version }}
override: true

- name: Build and Test
run: bash ci/github.sh
env:
RUST_VERSION: ${{ matrix.rust_version }}
EXHAUSTIVE_TZ: ${{ matrix.exhaustive_tz }}

lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Lint
run: bash ci/lint.sh
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
with:
check_together: 'y'

no_std:
strategy:
matrix:
os: [macos-latest, ubuntu-latest]

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2

- name: Install rust with no_std toolchain
if: ${{ matrix.core == 'no_std' }}
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust_version }}
toolchain: stable
target: thumbv6m-none-eabi
override: true

- name: Build no_std lib
run: cargo build --target thumbv6m-none-eabi --color=always
working-directory: ./ci/core-test

wasm:
strategy:
matrix:
os: [macos-latest, ubuntu-latest]

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2

- name: Install rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: wasm32-unknown-unknown
override: true

- name: Install node
if: ${{ matrix.wasm == 'yes_wasm' }}
uses: actions/setup-node@v1
with:
node-version: '12'

- name: Install wasm-pack
run: |
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
wasm-pack --version
- name: Build and Test
run: bash ci/github.sh
env:
RUST_VERSION: ${{ matrix.rust_version }}
CORE: ${{ matrix.core }}
WASM: ${{ matrix.wasm }}
EXHAUSTIVE_TZ: ${{ matrix.exhaustive_tz }}
KIND: ${{ matrix.kind }}
RUST_VERSION: stable
WASM: wasm_simple
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
[![Chrono on docs.rs][docsrs-image]][docsrs]
[![Join the chat at https://gitter.im/chrono-rs/chrono][gitter-image]][gitter]

[gh-image]: https://github.com/chronotope/chrono/workflows/Test/badge.svg
[gh-checks]: https://github.com/chronotope/chrono/actions?query=workflow%3ATest
[gh-image]: https://github.com/chronotope/chrono/workflows/test/badge.svg
[gh-checks]: https://github.com/chronotope/chrono/actions?query=workflow%3Atest
[cratesio-image]: https://img.shields.io/crates/v/chrono.svg
[cratesio]: https://crates.io/crates/chrono
[docsrs-image]: https://docs.rs/chrono/badge.svg
Expand Down
19 changes: 19 additions & 0 deletions ci/_shlib.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

# Use github workflow commands to make sections of the tests more obvious
# https://help.github.com/en/actions/reference/workflow-commands-for-github-actions


# Run a test as a "group" -- output will be folded and hidden by default
runt() {
echo "::group::$*"
# stdout is occasionally swallowed by gh actions
"$@" >&2
echo "::endgroup::$*"
}

runv() {
echo "🚀>$ $*" >&2
# stdout is occasionally swallowed by gh actions
"$@" >&2
}
8 changes: 4 additions & 4 deletions ci/fix-readme.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ echo '
[![Chrono on docs.rs][docsrs-image]][docsrs]
[![Join the chat at https://gitter.im/chrono-rs/chrono][gitter-image]][gitter]
[gh-image]: https://github.com/chronotope/chrono/workflows/Test/badge.svg
[gh-checks]: https://github.com/chronotope/chrono/actions?query=workflow%3ATest
[gh-image]: https://github.com/chronotope/chrono/workflows/test/badge.svg
[gh-checks]: https://github.com/chronotope/chrono/actions?query=workflow%3Atest
[cratesio-image]: https://img.shields.io/crates/v/chrono.svg
[cratesio]: https://crates.io/crates/chrono
[docsrs-image]: https://docs.rs/chrono/badge.svg
Expand All @@ -24,9 +24,9 @@ echo '

# print the section between the header and the usage
awk '/^\/\/! # Chrono:/,/^\/\/! ## /' "$LIB" | cut -b 5- | grep -v '^#' | \
sed 's/](\.\//](https:\/\/docs.rs\/chrono\/'$VERSION'\/chrono\//g'
sed 's/](\.\//](https:\/\/docs.rs\/chrono\/'"$VERSION"'\/chrono\//g'
echo
# Replace relative doc links with links to this exact version of docs on
# docs.rs
awk '/^\/\/! ## /,!/^\/\/!/' "$LIB" | cut -b 5- | grep -v '^# ' | \
sed 's/](\.\//](https:\/\/docs.rs\/chrono\/'$VERSION'\/chrono\//g' \
sed 's/](\.\//](https:\/\/docs.rs\/chrono\/'"$VERSION"'\/chrono\//g' \
61 changes: 34 additions & 27 deletions ci/github.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,51 @@

set -euo pipefail

# shellcheck source=ci/_shlib.sh
source "${BASH_SOURCE[0]%/*}/_shlib.sh"

TEST_TZS=(ACST-9:30 EST4 UTC0 Asia/Katmandu)
FEATURES=(std serde clock "alloc serde")
RUST_113_FEATURES=(rustc-serialize serde)

main() {
if [[ $RUST_VERSION != 1.13.0 ]]; then
if [[ $KIND == lint ]]; then
do_lints
elif [[ $WASM == yes_wasm ]]; then
if [[ "$*" =~ "-h" ]]; then
echo -n "usage: ENV_VARS... $0
Recognized environment variables. Their values are as they are so that they are
meaningful in the github actions feature matrix UI.
RUST_VERSION The rust version currently being tested
This doesn't set the version, it is just used to test
WASM Empty or 'yes_wasm'
CORE 'std' or 'no_std'
EXHAUSTIVE_TZ Emptly or 'all_tzs'
"
exit
fi

runv cargo --version

if [[ ${RUST_VERSION:-} != 1.13.0 ]]; then
if [[ ${WASM:-} == yes_wasm ]]; then
test_wasm
elif [[ $CORE == no_std ]]; then
elif [[ ${WASM:-} == wasm_simple ]]; then
test_wasm_simple
elif [[ ${CORE:-} == no_std ]]; then
test_core
elif [[ $EXHAUSTIVE_TZ == y ]]; then
elif [[ ${EXHAUSTIVE_TZ:-} == all_tzs ]]; then
test_all_tzs
else
test_regular UTC0
fi
elif [[ $RUST_VERSION == 1.13.0 ]]; then
elif [[ ${RUST_VERSION:-} == 1.13.0 ]]; then
test_113
else
echo "ERROR: didn't run any tests"
exit 1
fi
}

do_lints() {
# TODO: get clippy clean
# runt cargo clippy --color=always || true
runt make readme
runv git diff --exit-code -- README.md
}

test_all_tzs() {
for tz in "${TEST_TZS[@]}"; do
test_regular "$tz"
Expand Down Expand Up @@ -69,24 +82,18 @@ test_wasm() {
exit 1
fi
if ! command -v wasm-pack >/dev/null; then
echo ">$ curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh" >&2
echo "::group::curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh"
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
runv wasm-pack --version
fi
test_wasm_simple
}

test_wasm_simple() {
now=$(date +%s)
for tz in "${TEST_TZS[@]}"; do
runt env TZ="$tz" NOW="$now" wasm-pack test --node -- --features wasmbind
done
}

runt() {
echo "======================================================================" >&2
runv "$@"
}

runv() {
echo ">$ $*" >&2
# stdout is swallowed by gh actions
"$@" >&2
}

main
main "$@"
15 changes: 15 additions & 0 deletions ci/lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

set -euo pipefail

# shellcheck source=ci/_shlib.sh
source "${BASH_SOURCE[0]%/*}/_shlib.sh"

main() {
# TODO: get clippy clean
# runt cargo clippy --color=always || true
runt make readme
runv git diff --exit-code -- README.md
}

main
2 changes: 1 addition & 1 deletion tests/wasm.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[cfg(all(target_arch = "wasm32", not(target_os = "wasi"), feature = "wasmbind"))]
#[cfg(all(test, feature = "wasmbind"))]
mod test {
extern crate chrono;
extern crate wasm_bindgen_test;
Expand Down

0 comments on commit c2fe38c

Please sign in to comment.