{"id":22511136,"url":"https://github.com/renderedtext/when","last_synced_at":"2025-08-02T01:13:56.233Z","repository":{"id":34632873,"uuid":"179686225","full_name":"renderedtext/when","owner":"renderedtext","description":null,"archived":false,"fork":false,"pushed_at":"2024-08-29T09:23:45.000Z","size":2304,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-08-29T10:35:01.863Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Erlang","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/renderedtext.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-05T13:26:24.000Z","updated_at":"2024-08-28T10:11:29.000Z","dependencies_parsed_at":"2024-08-29T10:34:21.376Z","dependency_job_id":null,"html_url":"https://github.com/renderedtext/when","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/renderedtext%2Fwhen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/renderedtext%2Fwhen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/renderedtext%2Fwhen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/renderedtext%2Fwhen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/renderedtext","download_url":"https://codeload.github.com/renderedtext/when/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228548583,"owners_count":17935226,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-12-07T02:09:13.193Z","updated_at":"2025-08-02T01:13:56.205Z","avatar_url":"https://github.com/renderedtext.png","language":"Erlang","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WHEN library\n\nPurpose of this library is to evaluate conditional expressions written in\ndomain specific language defined in `Conditions DSL` section bellow for given\nset of parameters.\n\nEach condition will be evaluated either as true or false for given set of parameters\nif it is valid expression in `Conditions DSL`, otherwise error is returned.\n\n## Usage\n\n\nJust add it to your `mix.exs` file:\n```\n{:when, github: \"renderedtext/when\"}\n```\nand then you can evaluate string `condition` written in `Conditions DSL` with:\n```\nWhen.evaluate(condition, parameters)\n```\nwhere `parameters` is map containing `{keyword, value}` pairs for each keyword that appears in `condition` string.\n\n## Conditions DSL\n\nFormal language definition in [extended Backus-Naur Form (EBNF)](https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form) notation:\n\n```\nexpression = expression bool_operator term\n           | term\n\nterm = \"(\" expression \")\"      \n     | keyword operator string\n     | string operator keyword\n     | string                  \n     | boolean\n\nbool_operator = \"and\" | \"AND\" | \"or\" | \"OR\"\n\nkeyword = \"branch\" | \"BRANCH\" | \"tag\" | \"TAG\" | \"pull_request\" | \"PULL_REQUEST\" |\n \"result\" | \"RESULT\" | \"result_reason\" | \"RESULT_REASON\"\n\noperator = \"=\" | \"!=\" | \"=~\" | \"!~\"\n\nboolean = \"true\" | \"TRUE\" | \"false\" | \"FALSE\"\n\nstring = ? all characters between two single quotes, e.g. 'master' ?\n```           \n\nEach `keyword` in passed expression is replaced with passed value from `parameters` map when expression is evaluated, and then operations identified with one of the `operators` from above are executed with those values.\n\n|    KEYWORD     |                 MEANING                          |\n| :------------- | :----------------------------------------------- |\n| branch         | Name of the GitHub branch from which originated the pipeline that is being executed. |\n| tag            | Name of the GitHub tag from which originated the pipeline that is being executed. |\n| pull_request   | Number (as string) of GitHub pull request from which originated the pipeline that is being executed. |\n| result         | Execution result of pipeline, block, or job. Possible values are: passed, stopped, canceled and failed. |\n| result_reason  | The reason for given result of execution. Possible values are: test, malformed, stuck, deleted, internal and user. |\n\n\n|  OPERATOR |                 OPERATION RESULT                          |\n| :-------: | :-------------------------------------------------------- |\n|   =       | True if keyword value and given string are equal          |\n|   !=      | True if keyword value and given string are not equal      |\n|   =~      | True if keyword value and given PCRE* string match        |\n|   !~      | True if keyword value and given PCRE* string do not match |\n|   and     | True if expressions on both sides are true                |\n|   or      | True if at least one of two expressions is true           |\n\n\\* PCRE = Perl Compatible Regular Expression\n\n\n# YAML usage examples\n\n## Promotions\n\n### Promote automatically always\n\n```yaml\npromotions:\n  - name: Deploy to production\n    pipeline_file: prod.yml\n    auto:\n      when: \"true\"\n```    \n\n### Promote automatically on any branch and any result\n\n```yaml\npromotions:\n  - name: Deploy to production\n    pipeline_file: prod.yml\n    auto:\n      when: \"branch =~ '.*' AND result =~ '.*'\"\n```\n\n### Promote automatically on any branch and result is passed\n\n```yaml\npromotions:\n  - name: Deploy to production\n    pipeline_file: prod.yml\n    auto:\n      when: \"branch =~ '.*' AND result = 'passed'\"\n```\n\n### Promote automatically only when master result is passed\n\n```yaml\npromotions:\n  - name: Deploy to production\n    pipeline_file: prod.yml\n    auto:\n      when: \"branch = 'master' AND result = 'passed'\"\n```\n\n### Promote automatically only master branch\n\n```yaml\npromotions:\n  - name: Deploy to production\n    pipeline_file: prod.yml\n    auto:\n      when: \"branch = 'master'\"\n```\n\n### Promote automatically all branches that start with “df/”\n\n```yaml\npromotions:\n  - name: Deploy to production\n    pipeline_file: prod.yml\n    auto:\n      when: \"branch =~ '^df\\/'\"\n```\n\n### Promote automatically on staging or master branches\n\n```yaml\npromotions:\n  - name: Deploy to production\n    pipeline_file: prod.yml\n    auto:\n      when: \"branch = 'staging' OR branch = 'master'\"\n```\n\n### Promote automatically on any tag\n\n```yaml\npromotions:\n  - name: Deploy to production\n    pipeline_file: prod.yml\n    auto:\n      when: \"tag =~ '.*'\"\n```\n\n### Promote automatically if tag starts with “v1.”\n\n```yaml\npromotions:\n  - name: Deploy to production\n    pipeline_file: prod.yml\n    auto:\n      when: \"tag =~ '^v1\\.'\"\n```\n\n\n### Promote automatically if tag starts with \"v1.\" and result is passed\n\n```yaml\npromotions:\n  - name: Deploy to production\n    pipeline_file: prod.yml\n    auto:\n      when: \"tag =~ '^v1\\.' AND result = 'passed'\"\n```\n\n### Promote automatically on master branch and tags\n\n```yaml\npromotions:\n  - name: Deploy to production\n    pipeline_file: prod.yml\n    auto:\n      when: \"branch = 'master' OR tag =~ '.*'\"\n```\n\n### Promote automatically on master branch and tags when the result is passed\n\n```yaml\npromotions:\n  - name: Deploy to production\n    pipeline_file: prod.yml\n    auto:\n      when: \"(branch = 'master' OR tag =~ '.*') AND result = 'passed'\"\n```\n\n## Skip block execution\n\n### Skip always\n\n```yaml\nblocks:\n  - name: Unit tests\n    skip:\n      when: \"true\"\n```\n\n### Skip on any branch\n\n```yaml\nblocks:\n  - name: Unit tests\n    skip:\n      when: \"branch = '.*'\"\n```\n\n### Skip when master\n\n```yaml\nblocks:\n  - name: Unit tests\n    skip:\n      when: \"branch = 'master'\"\n```\n\n### Skip when branch starts with “df/”\n\n```yaml\nblocks:\n  - name: Unit tests\n    skip:\n      when: \"branch =~ '^df\\/'\"\n```\n\n### Skip when branch is staging or master\n\n```yaml\nblocks:\n  - name: Unit tests\n    skip:\n      when: \"branch = 'staging' OR branch = 'master'\"\n```\n\n### Skip on any tag\n\n```yaml\nblocks:\n  - name: Unit tests\n    skip:\n      when: \"tag =~ '.*'\"\n```\n\n### Skip when tag start with “v1.”\n\n```yaml\nblocks:\n  - name: Unit tests\n    skip:\n      when: \"tag =~ '^v1\\.'\"\n```\n\n### Skip on master branch and any tags\n\n```yaml\nblocks:\n  - name: Unit tests\n    skip:\n      when: \"branch = 'master' OR tag =~ '.*'\"\n```\n\n### Execute when branch starts with “dev/” == Skip when branch doesn’t start with dev/\n\n```yaml\nblocks:\n  - name: Unit tests\n    skip:\n      when: \"branch !~ '^dev\\/'\"\n```\n\n## Fail-fast\n\n### Stop running blocks *\n\n### Cancel pending blocks when a block fails\n\n```yaml\nfail_fast:\n  cancel:\n    when: \"true\"\n```\n\n### Cancel pending blocks when a block fails and on master branch\n\n```yaml\nfail_fast:\n  cancel:\n    when: \"branch = 'master'\"\n```\n\n### Cancel pending blocks when a block fails and branch starts with “df/”\n\n```yaml\nfail_fast:\n  cancel:\n    when: \"branch =~ '^df\\/'\"\n```\n\n### Cancel pending blocks when a block fails and branch is staging or master\n\n```yaml\nfail_fast:\n  cancel:\n    when: \"branch = 'staging' OR branch = 'master'\"\n```\n\n### Cancel pending blocks when a block fails and on any tag\n\n```yaml\nfail_fast:\n  cancel:\n    when: \"tag =~ '.*'\"\n```\n\n### Cancel pending blocks when a block fails and tag starts with “v1.”\n\n```yaml\nfail_fast:\n  cancel:\n    when: \"tag =~ '^v1\\.'\"\n```\n\n\n### Cancel pending blocks when a block fails and branch is master or any tag\n\n```yaml\nfail_fast:\n  cancel:\n    when: \"branch = 'master' OR tag =~ '.*'\"\n```\n\n### Cancel pending blocks when a block fails and branch doesn’t start with “dev/”\n\n```yaml\nfail_fast:\n  cancel:\n    when: \"tag !~ '^dev\\/'\"\n```\n\n## Scheduling strategies\n\n```yaml\nqueue:\n  mode:\n    stop:\n      when: \"branch = 'master' OR tag =~ '.*'\"\n    cancel:\n      when: \"tag =~ '.*'\"\n```\n\n## License\n\nThis software is licensed under [the Apache 2.0 license](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frenderedtext%2Fwhen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frenderedtext%2Fwhen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frenderedtext%2Fwhen/lists"}