added a python script for testing and a drone config for CI

This commit is contained in:
Lynne Megido 2021-02-28 21:08:35 +10:00
parent 809df5bc0e
commit bcd77d9ed6
Signed by: lynnesbian
GPG Key ID: F0A184B5213D9F90
4 changed files with 50 additions and 1 deletions

10
.drone.yml Normal file
View File

@ -0,0 +1,10 @@
---
kind: pipeline
type: docker
name: default
steps:
- name: build
image: rust:latest
commands:
- cargo test

1
.gitignore vendored
View File

@ -2,6 +2,7 @@
/imgs
fif_*
/old
/.mypy_cache
*.sh
!clippy.sh
cargo-timing*.html

View File

@ -10,7 +10,7 @@ repository = "https://git.bune.city/lynnesbian/fif"
readme = "README.md"
keywords = ["mime", "mimetype", "utilities", "tools"]
categories = ["command-line-utilities"]
exclude = [".idea/", "Cross.toml", "*.sh"]
exclude = [".idea/", "Cross.toml", "*.sh", "*.py", ".drone.yml"]
#resolver = "2"
#license-file = "LICENSE"

38
test.py Executable file
View File

@ -0,0 +1,38 @@
#!/usr/bin/env python
import re
import subprocess
def main():
match = re.search(
r'rust-version ?= ?"([\d.]+)"',
open("Cargo.toml", "r").read(-1)
)
if not match:
print("Couldn't find rust-version")
exit(1)
versions = [match.group(1), "stable", "beta", "nightly"]
backends = ["xdg-mime", "infer"]
done = 0
target = len(versions) * len(backends) * 2
for version in versions:
for backend in backends:
print(f"[{version}, {backend}] Tests")
subprocess.run(f"cargo +{version} test --features={backend}-backend".split(" "))
done += 1
print(f"Success - {done} of {target} complete")
print(f"[{version}, {backend}] Scanning imgs")
subprocess.run(f"cargo +{version} run --release --features={backend}-backend -- -E images imgs".split(" "))
done += 1
print(f"Success - {done} of {target} complete")
print("Done! You might want to run cargo clean...")
if __name__ == "__main__":
main()