Skip to content
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.

Commit

Permalink
Improve gh-actions
Browse files Browse the repository at this point in the history
  • Loading branch information
zakarumych committed Jun 16, 2020
1 parent c291957 commit 63ca0aa
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 41 deletions.
80 changes: 70 additions & 10 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,80 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
rust-toolchain: [stable, nightly]
target:
- i686-pc-windows-gnu
- i686-pc-windows-msvc
- i686-unknown-linux-gnu
- x86_64-apple-darwin
- x86_64-pc-windows-gnu
- x86_64-pc-windows-msvc
- x86_64-unknown-linux-gnu
- wasm32-unknown-unknown

steps:
- uses: actions/checkout@v2
- name: Install nightly toolchain with clippy available
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust-toolchain }}
target: ${{ matrix.target }}
override: true
- name: Run cargo check
uses: actions-rs/cargo@v1
with:
command: check
args: --all

- name: Run cargo test
uses: actions-rs/cargo@v1
with:
command: test
args: --all

lints:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install nightly toolchain with clippy available
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
components: rustfmt, clippy
- name: Run cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

- name: Run cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: -- -D warnings

features:
runs-on: ubuntu-latest
strategy:
matrix:
rust-toolchain: [stable, nightly]
target:
- i686-unknown-linux-gnu
- wasm32-unknown-unknown
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust-toolchain }}
target: ${{ matrix.target }}
override: true
- uses: actions/setup-python@v2
with:
python-version: '3.8.*'
architecture: 'x64'
- name: Install stable
run: rustup install stable && rustup update stable && rustup +stable target install wasm32-unknown-unknown
- name: Install nightly
run: rustup install nightly && rustup update nightly && rustup +nightly target install wasm32-unknown-unknown
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
- name: Check all permutations
if: ${{ matrix.os != 'windows-latest' }}
run: python check.py
run: python check.py ${{ matrix.target }}
52 changes: 21 additions & 31 deletions check.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@ def powerset(input):
return subset + with_pivot


async def run_check(*, toolchain, target=None, features=[]):
args = [f'+{toolchain}', 'check',
'--no-default-features', '--examples']
if target is not None:
args.append(f'--target={target}')
async def run_check(*, target, features=[]):
args = ['check', f'--target={target}', '--no-default-features',
'--all']
if len(features) > 0:
args.append(f'--features={",".join(features)}')

Expand All @@ -37,7 +35,7 @@ async def run_check(*, toolchain, target=None, features=[]):
print(f'`cargo {" ".join(args)}` succeeded')


async def run():
async def run(target):
_permutate_features = [
"std",
]
Expand All @@ -51,43 +49,35 @@ async def run():
]

checks = []
if target == "wasm32-unknown-unknown":
permutate_features = _permutate_features
iterate_features = _iterate_features + \
["fetch", "wasm-bindgen-spawn"]
else:
permutate_features = _permutate_features + ["sync"]
iterate_features = _iterate_features + ["reqwest-default-tls",
"reqwest-native-tls",
"reqwest-rustls-tls",
"tokio-spawn"]

for target in [None, "wasm32-unknown-unknown"]:
if target == "wasm32-unknown-unknown":
permutate_features = _permutate_features
iterate_features = _iterate_features + \
["fetch", "wasm-bindgen-spawn"]
else:
permutate_features = _permutate_features + ["sync"]
iterate_features = _iterate_features + ["reqwest-default-tls",
"reqwest-native-tls",
"reqwest-rustls-tls",
"tokio-spawn"]

toolchains = [
"stable",
"nightly",
]

for toolchain in toolchains:
for feature in iterate_features:
for subset in powerset(permutate_features):
checks.append(run_check(features=subset + [feature],
toolchain=toolchain,
target=target))
for feature in iterate_features:
for subset in powerset(permutate_features):
checks.append(run_check(features=subset + [feature],
target=target))

await asyncio.gather(*checks)


def main():
(major, minor, micro, _, _) = sys.version_info
target = sys.argv[1]
if major >= 3:
if minor >= 7:
asyncio.run(run())
asyncio.run(run(target))
return
elif minor >= 4:
loop = asyncio.get_event_loop()
loop.run_until_complete(run())
loop.run_until_complete(run(target))
loop.close()
return

Expand Down

0 comments on commit 63ca0aa

Please sign in to comment.