Skip to content

Commit

Permalink
ci(rust): github workflow to verify new crates that are being introduced
Browse files Browse the repository at this point in the history
  • Loading branch information
PsychoPunkSage committed Jul 19, 2024
1 parent eaa29ba commit 17cf5e7
Showing 1 changed file with 103 additions and 9 deletions.
112 changes: 103 additions & 9 deletions .github/workflows/check_crate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ name: Check Crates
on:
push:
branches:
- main
- develop
pull_request:
branches:
- main
- develop

jobs:
check_crates:
Expand All @@ -28,12 +28,13 @@ jobs:
profile: minimal
override: true

- name: Read member paths from main Cargo.toml
- name: Install tomlq
run: cargo install --locked tomlq --version 0.1.0

- name: Read member paths from implementations/rust/ockam directory
id: member_paths
run: |
paths=$(grep -oP '(?<=members = \[).*(?=\])' Cargo.toml | tr -d '\n')
paths=$(echo "$paths" | sed 's/,/\n/g' | tr -d '"')
echo "::set-output name=paths::$paths"
paths=$(find implementations/rust/ockam -name Cargo.toml)
- name: Check for CHANGELOG.md
run: |
Expand Down Expand Up @@ -65,14 +66,107 @@ jobs:
- name: Validate Cargo.toml categories
run: |
allowed_categories=$(curl -s https://crates.io/category_slugs | jq -r '.[]')
allowed_categories="
accessibility
aerospace
aerospace::drones
aerospace::protocols
aerospace::simulation
aerospace::space-protocols
aerospace::unmanned-aerial-vehicles
algorithms
api-bindings
asynchronous
authentication
caching
command-line-interface
command-line-utilities
compilers
compression
computer-vision
concurrency
config
cryptography
cryptography::cryptocurrencies
data-structures
database
database-implementations
date-and-time
development-tools
development-tools::build-utils
development-tools::cargo-plugins
development-tools::debugging
development-tools::ffi
development-tools::procedural-macro-helpers
development-tools::profiling
development-tools::testing
email
embedded
emulators
encoding
external-ffi-bindings
filesystem
finance
game-development
game-engines
games
graphics
gui
hardware-support
internationalization
localization
mathematics
memory-management
multimedia
multimedia::audio
multimedia::encoding
multimedia::images
multimedia::video
network-programming
no-std
no-std::no-alloc
os
os::android-apis
os::freebsd-apis
os::linux-apis
os::macos-apis
os::unix-apis
os::windows-apis
parser-implementations
parsing
rendering
rendering::data-formats
rendering::engine
rendering::graphics-api
rust-patterns
science
science::bioinformatics
science::bioinformatics::genomics
science::bioinformatics::proteomics
science::bioinformatics::sequence-analysis
science::geo
science::neuroscience
science::robotics
simulation
template-engine
text-editors
text-processing
value-formatting
virtualization
visualization
wasm
web-programming
web-programming::http-client
web-programming::http-server
web-programming::websocket
"
paths="${{ steps.member_paths.outputs.paths }}"
IFS=$'\n' read -r -d '' -a path_array <<< "$paths"
for path in "${path_array[@]}"; do
for crate in $(find $path -name 'Cargo.toml'); do
categories=$(grep -A 10 '\[package\]' $crate | grep -m 1 'categories' | sed 's/categories = \[\(.*\)\]/\1/' | tr -d '[],' | tr -d ' ' | tr ',' '\n')
categories=$(tomlq package.categories -f "$crate" | jq -r '.[]')
for category in $categories; do
if ! echo "$allowed_categories" | grep -q "^$category$"; then
if ! echo "$allowed_categories" | grep -q "$category"; then
echo "Error: $crate contains invalid category $category"
exit 1
fi
Expand Down

0 comments on commit 17cf5e7

Please sign in to comment.