{"id":19500654,"url":"https://github.com/reactioncommerce/ci-scripts","last_synced_at":"2025-04-25T23:30:35.288Z","repository":{"id":47913140,"uuid":"200098795","full_name":"reactioncommerce/ci-scripts","owner":"reactioncommerce","description":"Scripts supporting our Continuous Integration (CI)","archived":false,"fork":false,"pushed_at":"2021-08-11T22:20:24.000Z","size":75,"stargazers_count":8,"open_issues_count":4,"forks_count":4,"subscribers_count":15,"default_branch":"trunk","last_synced_at":"2025-04-04T04:51:09.649Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/reactioncommerce.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}},"created_at":"2019-08-01T18:14:03.000Z","updated_at":"2022-06-04T06:22:09.000Z","dependencies_parsed_at":"2022-08-30T00:11:55.615Z","dependency_job_id":null,"html_url":"https://github.com/reactioncommerce/ci-scripts","commit_stats":null,"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reactioncommerce%2Fci-scripts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reactioncommerce%2Fci-scripts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reactioncommerce%2Fci-scripts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reactioncommerce%2Fci-scripts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/reactioncommerce","download_url":"https://codeload.github.com/reactioncommerce/ci-scripts/tar.gz/refs/heads/trunk","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250912660,"owners_count":21506865,"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-11-10T22:09:24.012Z","updated_at":"2025-04-25T23:30:35.027Z","avatar_url":"https://github.com/reactioncommerce.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Reaction Commerce CI Scripts\n\nScripts we use across many repositories during continuous integration.\n\n## How to use in circleci\n\nIn your `.circleci/config.yml`, in your appropriate job step, add a run command:\n\n```yaml\njobs:\n  lint:\n    \u003c\u003c: *defaults\n    steps:\n      - checkout\n      - setup_remote_docker:\n          docker_layer_caching: true\n      - run:\n          name: Run Lint Suite\n          # pin the current latest version explicitly, 1.8.4 for example only\n          command: npx --quiet --package @reactioncommerce/ci-scripts@1.8.4 lint-shell-scripts\n```\n\n**Note:** Most `docker-*` scripts as well as `lint-dockerfiles` require the `setup_remote_docker` circleci job step as a prerequisite. Be sure your `config.yml` has that when it's needed.\n\nIf you run a bunch of these and want to DRY it up, try this flavor with an environment variable:\n\n```yaml\n# The following stanza defines a map named defaults with a variable that may be\n# inserted using the YAML merge (\u003c\u003c: *) key later in the file to save some\n# typing. See http://yaml.org/type/merge.html for details.\ndefaults: \u0026defaults\n  docker:\n    - image: circleci/node:12-stretch\n  environment:\n    CI_SCRIPTS: 'npx --quiet --package @reactioncommerce/ci-scripts@1.8.4'\njobs:\n  docker-build-tag-push:\n    \u003c\u003c: *defaults\n    steps:\n      - checkout\n      - setup_remote_docker:\n          docker_layer_caching: true\n      - run:\n          name: 'docker: catalog-publisher'\n          command: |\n            ${CI_SCRIPTS} docker-labels \u003e\u003e Dockerfile\n            ${CI_SCRIPTS} build-metadata\n            ${CI_SCRIPTS} docker-build-tag-push . reactioncommerce/catalog-publisher\n```\n\n## How to add new scripts\n\n- Put your script file in the repo root. Use a filename extension. It makes editor syntax highlighting and linting \"just work\" sometimes.\n- `chmod 755 your-script.sh`\n- Add an entry to the `package.json` `\"bin\"` property mapping `\"name-without-extension\": \"./name-with-extension.sh\",`\n- Commit, being sure to prefix your commit message with `feat: ` so semantic release publishes a new minor version properly\n- Notes on filename extensions vs no extensions\n  - In the `package.json` `bin` keys, we omit the extension. This is slightly nicer as a command line interface. It's just a logical script name.\n  - When launching via `npx` on the command line during CI, it's **no extension**\n  - In the repo root dir, we **do** use the extension since this is nicer for editor syntax detection, development tools, etc.\n  - So in `package.json` `bin` it's **no extension** for the key but **yes extension** for the value\n  - When calling one ci-script from another ci-script it's **no extension** because these run from the `node_modules/.bin` directory which only contains no-extension files which npm picks up from `package.json` `bin` key.\n\n## How to troubleshoot script errors\n\n- Launch the docker image your CI job uses locally\n  - For example\n    - `docker run --rm -it circleci/node:12 bash`\n- Install ci-scripts in /tmp so you can debug\n- `cd /tmp \u0026\u0026 npm install @reactioncommerce/ci-scripts`\n- Run with debugging\n- `bash -x ./node_modules/@reactioncommerce/ci-scripts/script-you-want-to-debug.sh`\n\n## Implementation Notes\n\n- Scripts should operate on their current working directory (inherited from the parent process)\n  - Meaning the calling code should `cd` into the root of their project git repository (which happens by default on circleci) then invoke the scripts from this repo\n- Scripts should enumerate files with `git ls-files`\n- Shell scripts should be formatted with [shfmt](https://github.com/mvdan/sh)\n- If you need to call another ci-script from your own ci-script, use this pattern\n  1. Make a variable for the directory the script lives in, which is `node_modules/.bin` when running via npx\n    - `ci_scripts_dir=\"$(dirname \"${BASH_SOURCE[0]}\")\"`\n  2. Reference sibling scripts with no extension\n    - `./some-other-script`\n    \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freactioncommerce%2Fci-scripts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freactioncommerce%2Fci-scripts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freactioncommerce%2Fci-scripts/lists"}