{"id":17208686,"url":"https://github.com/chevdor/ruled_labels","last_synced_at":"2026-03-05T02:04:30.492Z","repository":{"id":62211884,"uuid":"525475352","full_name":"chevdor/ruled_labels","owner":"chevdor","description":"Assuming you prefix your labels, this cli will help you define the rules required for labelling. For instance a high prio bug cannot be labelled low prio...","archived":false,"fork":false,"pushed_at":"2025-02-11T15:00:42.000Z","size":303,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-10-12T05:25:41.677Z","etag":null,"topics":["chevdor","cli","github","label","labels","rules","rust","yaml"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chevdor.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2022-08-16T17:16:04.000Z","updated_at":"2025-02-11T15:00:46.000Z","dependencies_parsed_at":"2023-02-09T12:15:20.249Z","dependency_job_id":"f6242464-8e98-414d-8f91-1eee3dc44772","html_url":"https://github.com/chevdor/ruled_labels","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/chevdor/ruled_labels","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chevdor%2Fruled_labels","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chevdor%2Fruled_labels/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chevdor%2Fruled_labels/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chevdor%2Fruled_labels/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chevdor","download_url":"https://codeload.github.com/chevdor/ruled_labels/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chevdor%2Fruled_labels/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30106183,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T01:39:18.192Z","status":"online","status_checked_at":"2026-03-05T02:00:06.710Z","response_time":93,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chevdor","cli","github","label","labels","rules","rust","yaml"],"created_at":"2024-10-15T02:49:38.670Z","updated_at":"2026-03-05T02:04:30.462Z","avatar_url":"https://github.com/chevdor.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ruled Labels\n\n\u003cfigure\u003e\n\u003cimg src=\"https://github.com/chevdor/ruled_labels/actions/workflows/quick-check.yml/badge.svg?branch=master\" alt=\"badge\" /\u003e\n\u003c/figure\u003e\n\n## Intro\n\n`ruled-labels` is compatible with the `glabel` yaml format and allow specifying additionnal rules regarding the labels. Those rules are described in a yaml file.\n\n`ruled-labels` can handle:\n\n-   the list of labels and their properties\n\n-   the label rules\n\n-   a description of test cases\n\n## Getting started\n\nUpon doing the [Install](#install), a new command called `ruled-labels` will be available on your system\n\nThe minimum you will need is a [Rules](#specs) file. It is usually called `specs.yml` and `ruled-labels` will find it by default if you are using this name.\n\nHaving your [Rules](#specs), you can call `ruled-labels` to check a set of labels. Here is how it looks like:\n\n    ruled-labels check --labels A1,B1\n\nAlternatively, you can also call:\n\n    ruled-labels check -l A1 -l B1\n\nThe following calls are NOT valid:\n\n-   `ruled-labels check --labels A1, B1`\n\n-   `ruled-labels check --labels A1 B1`\n\nCheck out the [Usage](#usage) to learn more about the available commands. and options.\n\nIn most case, you will not call the check command manually, but let your CI take care of that.\n\nFirst, you may fetch the labels of your PR:\n\n    API_BASE=https://api.github.com/repos\n    REPO=...\n    GITHUB_PR=1234\n    labels=$( curl -H \"Authorization: token $GITHUB_TOKEN\" -s \"$API_BASE/$REPO/pulls/$GITHUB_PR\" | jq '.labels | .[] | .name' | tr \"\\n\" \",\")\n\nYou can now remove the leading `,` that is not useful:\n\n    labels_args=${labels: :-1}\n\nBefore using the `labels_args`, you want to ensure you are using `IFS=\",\"` so your shell does not split one label containing a space into 2 strings made of a valid label and one that will fail.\n\nAnd finally run the check:\n\n    ruled-labels check --dev --labels $labels_args\n\nIf you prefer using a docker image, here is how it looks like:\n\n    docker run --rm -i -e labels_args -v $PWD/:$MOUNT $IMAGE check $MOUNT/$CHECK_SPECS --dev --labels $labels_args\n\n## Install\n\nThere is currenly no binary package so you need to use `cargo` to build and install `ruled-labels` on your system.\n\n    cargo install --locked --git https://github.com/chevdor/ruled_labels\n\n## Docker\n\nIf you prefer not having to install Rust \u0026 Cargo and have Docker installed, you may prefer to run a dockerized version of `ruled-labels`. The next chapters explain how to proceed.\n\n### Run\n\nDocker commands can end up quite lenghty so you may like to set an alias:\n\n        alias ruled-labels='docker run --rm -it ruled-labels'\n\nAfter setting this alias, you may use `ruled-labels` by simply invoking the `ruled-labels` command:\n\n        ruled-labels --version\n\nIf you prefer a shorter a command, you may set an alias for `rl` instead of `ruled-labels`.\n\nThis is out of the scope of this documentation but note that you cannot just invoke `ruled-labels` check and expect it to work on your local `specs.yaml`. For that to work, you need to mount your `specs.yaml` into the container. That looks like this:\n\n        docker run --rm -it -v $PWD/specs.yaml:/usr/local/bin/specs.yaml \u003cliteral\u003eruled-labels\u003c/literal\u003e list\n\n### Build\n\nYou can pull the docker image from `chevdor`/`ruled-labels` or build you own:\n\n        docker build -t ruled-labels .\n\n## Features\n\n-   rule based engine\n\n-   rules defined as yaml\n\n-   `lint`: the lint command helps you validate your yaml files\n\n-   `list`: show a summary of your rules\n\n-   `test`: You can define a set of tests scenarii to check against your specs to ensure you did not leave anything behind\n\n-   `check`: CI can call this command to check a set of labels against your specs \u0026 rules\n\n# Usage\n\n## Help\n\n    This utility allows checking labels based on rules\n\n    Usage: ruled-labels [OPTIONS] \u003cCOMMAND\u003e\n\n    Commands:\n      list   List all the rules\n      lint   Lint the rules\n      check  Check label set against the rules\n      test   Run tests using rules and a test set\n      help   Print this message or the help of the given subcommand(s)\n\n    Options:\n          --no-color  Output without any coloring, this is useful for documentation and CI system where the color code pollute the output\n      -d, --dev       The output is more developer oriented\n      -h, --help      Print help information\n      -V, --version   Print version information\n\n## Lint\n\n    PASSED  The file specs.yaml looks OK\n\n## List\n\n    name: chevdor/glabel\n    desc: Import from chevdor/glabel\n    labels: 14\n    Rules:\n     - Some topics (X labels) (some_topics)\n     - Exactly one visibility label (b_rules)\n     - Note Worthy need one Prio label (b_need_p)\n     - Note Worthy implies no J label (b1_excludes_j)\n     - Exclude all Ds (exclude_all_d)\n     - Require all of J\n     - Require 1 P and no X (single_p_no_x) DISABLED\n\n## Test\n\n    Tests specs: tests.yaml\n    Specs file : specs.yaml\n\n        ▶️ Running test  1: Pass\n        PASSED  Pass\n\n        ▶️ Running test  2: Fail - b_rules\n    You need to include one of the B* label(s)\n        PASSED  Fail - b_rules\n\n        ▶️ Running test  3: Fail - some_topics\n    You need to include some of the J2, X1, X2 label(s)\n        PASSED  Fail - some_topics\n\n        ▶️ Running test  4: Fail - b_need_p\n    Since you have one of the B* label(s), you need to include one of the P* label(s) and you need to exclude all of the P1 label(s)\n        PASSED  Fail - b_need_p\n\n        ▶️ Running test  5: Fail - b1_excludes_j\n    Since you have one of the B1 label(s), you need to exclude all of the J* label(s)\n        PASSED  Fail - b1_excludes_j\n\n        ▶️ Running test  6: Fail - b1_excludes_j 2\n    Since you have one of the B1 label(s), you need to exclude all of the J* label(s)\n        PASSED  Fail - b1_excludes_j 2\n    PASSED  All expectations are OK\n\n## Check\n\n    s = \"B0\"\n    s = \"A1\"\n            FAILED  Some topics (X labels) | You need to include some of the X2, J2, X1 label(s)\n            PASSED  Exactly one visibility label | You need to include one of the B* label(s)\n            FAILED  Note Worthy need one Prio label | Since you have one of the B* label(s), you need to include one of the P* label(s) and you need to exclude all of the P1 label(s)\n            SKIPPED Note Worthy implies no J label | Since you have one of the B1 label(s), you need to exclude all of the J* label(s)\n            PASSED  Exclude all Ds | You need to exclude all of the D* label(s)\n            FAILED  Require all of J | You need to include all of the J* label(s)\n            SKIPPED Require 1 P and no X | You need to include one of the P* label(s) and you need to exclude all of the X1, X2 label(s)\n    FAILED  chevdor/glabel v0.1.0 for labels A1, B0\n\n## Vscode yaml\n\nAdd to the [yaml pluggin](https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml) (by RedHat) config:\n\n    \"yaml.customTags\": [\n        \"!none_of sequence\",\n        \"!one_of sequence\",\n        \"!some_of sequence\",\n        \"!all_of sequence\",\n    ]\n\n## Yaml specs\n\n## Rules\n\n    ---\n    # tag::header[]\n    name: chevdor/glabel\n    version: 0.1.0\n    description: Import from chevdor/glabel\n    # end::header[]\n\n    # tag::labels[]\n    labels:\n      - name: A1-foo\n        description: Foo\n        color: d73a4a\n      - name: A2-bar\n        description: Bar\n        color: d73a4a\n    # end::labels[]\n      - name: X1-frontend\n        description: Frontend\n        color: d73a4a\n      - name: X2-backend\n        description: Frontend\n        color: d73a4a\n      - name: X3-documentation\n        description: Improvements or additions to documentation\n        color: 0075ca\n      - name: P1-low_prio\n        description: Low prio\n        color: ffffff\n      - name: P2-low_prio\n        description: Low prio\n        color: ffffff\n      - name: P3-low_prio\n        description: Low prio\n        color: ffffff\n      - name: B0-silent\n        description: silent\n        color: ffffff\n      - name: B1-note_worthy\n        description: note worthy\n        color: ffffff\n      - name: B2-important\n        description: important\n        color: ffffff\n      - name: J1-junk1\n        description: junk1\n        color: ffffff\n      - name: J2-junk2\n        description: junk2\n        color: ffffff\n      - name: D1-disable1\n        description: diable1\n        color: ffffff\n\n    # tag::rules[]\n    rules:\n      - name: Some topics (X labels)\n        id: some_topics\n        spec:\n          require: !some_of\n            - X1\n            - X2\n            - J2\n    # end::rules[]\n\n      - name: Exactly one visibility label\n        id: b_rules\n        tags: [ CI ]\n        priority: 1000\n        description: |\n          This rule ensures we have a single visibility label.\n          It is important to void conflicts such as having a PR\n          labels as both important and unsubstantial.\n        spec:\n          require: !one_of\n            - B*\n          exclude: ~\n\n\n      - name: Note Worthy need one Prio label\n        id: b_need_p\n        tags: [v2, CI]\n        priority: 100\n        spec:\n          # when we have one of the B labels\n          when: !one_of\n            - B*\n          # we need exactly one of the P labels\n          require: !one_of\n            - P*\n          # but we don't want the P1 labels\n          exclude: !all_of\n            - P1\n\n      - name: Note Worthy implies no J label\n        id: b1_excludes_j\n        spec:\n          when: !one_of\n            - B1\n          exclude: !all_of\n            - J*\n\n      - name: Exclude all Ds\n        id: exclude_all_d\n        disabled: false   # default\n        priority: 100     # default\n        spec:\n          exclude: !all_of\n            - D*\n\n      - name: Require all of J\n        ide: require_all_j\n        spec:\n          require: !all_of\n            - J*\n\n      - name: Require 1 P and no X\n        id: single_p_no_x\n        disabled: true\n        spec:\n          require: !one_of\n            - P*\n          exclude: !all_of [\"X1\", \"X2\"]\n\n## Test\n\n    name: Name of the test\n    spec_file: specs.yaml\n\n    specs:\n      - name: Pass\n        only: true\n        labels:\n          - B0-silent\n          - X1-bar\n          - X2-bar\n          - X3-foobar\n          - J1\n          - J2\n          - P2\n        expected: true\n\n      - name: Fail - b_rules\n        filter:\n          id: [ b_rules ]\n        labels:\n          - B1-note_worthy\n          - B0-silent\n        expected: false\n\n      - name: Fail - some_topics\n        filter:\n          id: [ some_topics ]\n        skip: true\n        labels:\n          - B0-silent\n        expected: false\n\n      - name: Fail - b_need_p\n        filter:\n          id: [ b_need_p ]\n        labels:\n          - B1\n        expected: false\n\n      - name: Fail - b1_excludes_j\n        filter:\n          id: [ b1_excludes_j ]\n        labels:\n          - B1\n          - J1\n          - J2\n        expected: false\n\n      - name: Fail - b1_excludes_j 2\n        filter:\n          id: [ b1_excludes_j ]\n        labels:\n          - B1\n          - J1\n        expected: false\n\n## Glossary\n\nIn order to understand the terminology and what are `LabelMatch`, `LabelMatchSet`, `Labels`, `LabelId`, etc…​ please refer to the Rust documenation. You can generate and open it using:\n\n    cargo doc --no-deps --open\n\n## Licence\n\n    Copyright 2021-2022 - Wilfried Kopp aka. Chevdor \u003cchevdor@gmail.com\u003e\n\n    Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\n    The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\n    THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchevdor%2Fruled_labels","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchevdor%2Fruled_labels","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchevdor%2Fruled_labels/lists"}