diff --git a/.github/workflows/release-rubygem.yaml b/.github/workflows/release-rubygem.yaml index 5bf41056..928d599d 100644 --- a/.github/workflows/release-rubygem.yaml +++ b/.github/workflows/release-rubygem.yaml @@ -23,10 +23,6 @@ jobs: with: ruby-version: 4.0.6 working-directory: ruby - - name: Synchronize CiEnvironments.json - working-directory: ruby - run: bundle exec rake ci_environments - - run: ./scripts/fail-if-dirty - uses: rubygems/configure-rubygems-credentials@dc5a8d8553e6ee01fc26761a49e99e733d17954a # v2.1.0 - uses: cucumber/action-publish-rubygem@4e79bb9aed597c835e8438f57c04d0996ab80d72 # v2.0.0 with: diff --git a/.github/workflows/test-codegen.yaml b/.github/workflows/test-codegen.yaml new file mode 100644 index 00000000..da1f2eab --- /dev/null +++ b/.github/workflows/test-codegen.yaml @@ -0,0 +1,32 @@ +name: test-codegen + +permissions: {} + +on: + push: + branches: + - main + - renovate/** + pull_request: + branches: + - main + +jobs: + test-codegen: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: generate code for all languages + run: | + make clean-ci-environment + make copy-ci-environment + + - name: check the repo is still clean after generation + run: | + git status --porcelain + git diff HEAD + [ -z "$(git status --porcelain)" ] diff --git a/.github/workflows/test-go.yaml b/.github/workflows/test-go.yaml index 36073f9f..9fdc16ea 100644 --- a/.github/workflows/test-go.yaml +++ b/.github/workflows/test-go.yaml @@ -44,6 +44,3 @@ jobs: - name: Run go vet working-directory: go run: go vet ./... - - name: Run go test - working-directory: go - run: make test diff --git a/.github/workflows/test-java.yaml b/.github/workflows/test-java.yaml index 446f0b0f..80b8d701 100644 --- a/.github/workflows/test-java.yaml +++ b/.github/workflows/test-java.yaml @@ -48,4 +48,3 @@ jobs: working-directory: java - run: mvn test working-directory: java - - run: ./scripts/fail-if-dirty diff --git a/.github/workflows/test-javascript.yaml b/.github/workflows/test-javascript.yaml index 1ab77676..650d47b4 100644 --- a/.github/workflows/test-javascript.yaml +++ b/.github/workflows/test-javascript.yaml @@ -49,4 +49,3 @@ jobs: working-directory: javascript - run: npm run lint working-directory: javascript - - run: ./scripts/fail-if-dirty diff --git a/.github/workflows/test-ruby.yaml b/.github/workflows/test-ruby.yaml index bee8bb88..43211c97 100644 --- a/.github/workflows/test-ruby.yaml +++ b/.github/workflows/test-ruby.yaml @@ -45,4 +45,3 @@ jobs: working-directory: ruby - run: bundle exec rake working-directory: ruby - - run: ./scripts/fail-if-dirty diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 76e58b0b..f9f83251 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,12 +2,9 @@ Thank you for considering contributing to Cucumber ci-environment! -## Code of Conduct +Please read [cucumber/.github/CONTRIBUTING.md](https://github.com/cucumber/.github/blob/main/CONTRIBUTING.md) first. -Everyone interacting in this codebase and issue tracker is expected to follow -the Cucumber [code of conduct](https://cucumber.io/conduct). - -## Adding support for new CI servers +# Adding support for new CI servers If you want to see support for a new CI server, please submit a pull request. @@ -18,6 +15,8 @@ Here are the steps: `CiEnvironments.json`. * Add an approval test in `testdata/YourCi.txt` and `testdata/YourCi.txt.json`. +* Copy the `CiEnvironments.json` to the other projects by running `make copy-ci-environment`. + Then build and run the tests for all implementations: cd java && mvn clean install diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..28e094b9 --- /dev/null +++ b/Makefile @@ -0,0 +1,20 @@ +languages = go java javascript python ruby + +.DEFAULT_GOAL = help + +help: ## Show this help + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \n\nWhere is one of:\n"} /^[$$()% a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) + +copy-ci-environment: $(patsubst %,copy-ci-environment-%,$(languages)) ## Copy CiEnvironment.json to all supported languages +.PHONY: copy-ci-environment + +copy-ci-environment-%: % + $(MAKE) --directory=$< copy-ci-environment +.PHONY: generate-% + +clean-ci-environment: $(patsubst %,clean-ci-environment-%,$(languages)) ## Clean CiEnvironment.json +.PHONY: clean-ci-environment + +clean-ci-environment-%: % + $(MAKE) --directory=$< clean-ci-environment +.PHONY: clean-ci-environment-% diff --git a/go/CiEnvironments.json b/go/CiEnvironments.json index e58e651f..58ee9c75 100644 --- a/go/CiEnvironments.json +++ b/go/CiEnvironments.json @@ -1,150 +1,160 @@ [ { - "name": "Azure Pipelines", - "url": "${BUILD_BUILDURI}", "buildNumber": "${BUILD_BUILDNUMBER}", "git": { + "branch": "${BUILD_SOURCEBRANCH/refs/heads/(.*)/\\1}", "remote": "${BUILD_REPOSITORY_URI}", "revision": "${BUILD_SOURCEVERSION}", - "branch": "${BUILD_SOURCEBRANCH/refs\/heads\/(.*)/\\1}", - "tag": "${BUILD_SOURCEBRANCH/refs\/tags\/(.*)/\\1}" - } + "tag": "${BUILD_SOURCEBRANCH/refs/tags/(.*)/\\1}" + }, + "name": "Azure Pipelines", + "url": "${BUILD_BUILDURI}" }, { - "name": "Bamboo", - "url": "${bamboo_buildResultsUrl}", "buildNumber": "${bamboo_buildNumber}", "git": { + "branch": "${bamboo_planRepository_branch}", "remote": "${bamboo_planRepository_repositoryUrl}", - "revision": "${bamboo_planRepository_revision}", - "branch": "${bamboo_planRepository_branch}" - } + "revision": "${bamboo_planRepository_revision}" + }, + "name": "Bamboo", + "url": "${bamboo_buildResultsUrl}" }, { - "name": "Buddy", - "url": "${BUDDY_EXECUTION_URL}", "buildNumber": "${BUDDY_EXECUTION_ID}", "git": { + "branch": "${BUDDY_EXECUTION_BRANCH}", "remote": "${BUDDY_SCM_URL}", "revision": "${BUDDY_EXECUTION_REVISION}", - "branch": "${BUDDY_EXECUTION_BRANCH}", "tag": "${BUDDY_EXECUTION_TAG}" - } + }, + "name": "Buddy", + "url": "${BUDDY_EXECUTION_URL}" }, { - "name": "Bitrise", - "url": "${BITRISE_BUILD_URL}", "buildNumber": "${BITRISE_BUILD_NUMBER}", "git": { + "branch": "${BITRISE_GIT_BRANCH}", "remote": "${GIT_REPOSITORY_URL}", "revision": "${BITRISE_GIT_COMMIT}", - "branch": "${BITRISE_GIT_BRANCH}", "tag": "${BITRISE_GIT_TAG}" - } + }, + "name": "Bitrise", + "url": "${BITRISE_BUILD_URL}" }, { - "name": "CircleCI", - "url": "${CIRCLE_BUILD_URL}", "buildNumber": "${CIRCLE_BUILD_NUM}", "git": { + "branch": "${CIRCLE_BRANCH}", "remote": "${CIRCLE_REPOSITORY_URL}", "revision": "${CIRCLE_SHA1}", - "branch": "${CIRCLE_BRANCH}", "tag": "${CIRCLE_TAG}" - } + }, + "name": "CircleCI", + "url": "${CIRCLE_BUILD_URL}" }, { - "name": "CodeFresh", - "url": "${CF_BUILD_URL}", "buildNumber": "${CF_BUILD_ID}", "git": { + "branch": "${CF_BRANCH}", "remote": "${CF_COMMIT_URL/(.*)\\/commit.+$/\\1}.git", - "revision": "${CF_REVISION}", - "branch": "${CF_BRANCH}" - } + "revision": "${CF_REVISION}" + }, + "name": "CodeFresh", + "url": "${CF_BUILD_URL}" }, { - "name": "CodeShip", - "url": "${CI_BUILD_URL}", "buildNumber": "${CI_BUILD_NUMBER}", "git": { + "branch": "${CI_BRANCH}", "remote": "${CI_PULL_REQUEST/(.*)\\/pull\\/\\d+/\\1.git}", - "revision": "${CI_COMMIT_ID}", - "branch": "${CI_BRANCH}" - } + "revision": "${CI_COMMIT_ID}" + }, + "name": "CodeShip", + "url": "${CI_BUILD_URL}" }, { - "name": "GitHub Actions", - "url": "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}", "buildNumber": "${GITHUB_RUN_ID}", "git": { + "branch": "${GITHUB_HEAD_REF}", "remote": "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git", "revision": "${GITHUB_SHA}", - "branch": "${GITHUB_HEAD_REF}", - "tag": "${GITHUB_REF/refs\/tags\/(.*)/\\1}" - } + "tag": "${GITHUB_REF/refs/tags/(.*)/\\1}" + }, + "name": "GitHub Actions", + "url": "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" }, { - "name": "GitLab", - "url": "${CI_JOB_URL}", "buildNumber": "${CI_JOB_ID}", "git": { + "branch": "${CI_COMMIT_BRANCH}", "remote": "${CI_REPOSITORY_URL}", "revision": "${CI_COMMIT_SHA}", - "branch": "${CI_COMMIT_BRANCH}", "tag": "${CI_COMMIT_TAG}" - } + }, + "name": "GitLab", + "url": "${CI_JOB_URL}" }, { - "name": "GoCD", - "url": "${GO_SERVER_URL}/pipelines/${GO_PIPELINE_NAME}/${GO_PIPELINE_COUNTER}/${GO_STAGE_NAME}/${GO_STAGE_COUNTER}", "buildNumber": "${GO_PIPELINE_NAME}/${GO_PIPELINE_COUNTER}/${GO_STAGE_NAME}/${GO_STAGE_COUNTER}", "git": { + "branch": "${GO_SCM_*_PR_BRANCH/.*:(.*)/\\1}", "remote": "${GO_SCM_*_PR_URL/(.*)\\/pull\\/\\d+/\\1.git}", - "revision": "${GO_REVISION}", - "branch": "${GO_SCM_*_PR_BRANCH/.*:(.*)/\\1}" - } + "revision": "${GO_REVISION}" + }, + "name": "GoCD", + "url": "${GO_SERVER_URL}/pipelines/${GO_PIPELINE_NAME}/${GO_PIPELINE_COUNTER}/${GO_STAGE_NAME}/${GO_STAGE_COUNTER}" }, { - "name": "Jenkins", - "url": "${BUILD_URL}", "buildNumber": "${BUILD_NUMBER}", "git": { + "branch": "${GIT_LOCAL_BRANCH}", "remote": "${GIT_URL}", - "revision": "${GIT_COMMIT}", - "branch": "${GIT_LOCAL_BRANCH}" - } + "revision": "${GIT_COMMIT}" + }, + "name": "Jenkins", + "url": "${BUILD_URL}" + }, + { + "buildNumber": "${JB_SPACE_EXECUTION_NUMBER}", + "git": { + "branch": "${JB_SPACE_GIT_BRANCH}", + "remote": "https://${JB_SPACE_API_URL}/p/${JB_SPACE_PROJECT_KEY}/repositories/${JB_SPACE_GIT_REPOSITORY_NAME}", + "revision": "${JB_SPACE_GIT_REVISION}" + }, + "name": "JetBrains Space", + "url": "${JB_SPACE_EXECUTION_URL}" }, { - "name": "Semaphore", - "url": "${SEMAPHORE_ORGANIZATION_URL}/jobs/${SEMAPHORE_JOB_ID}", "buildNumber": "${SEMAPHORE_JOB_ID}", "git": { + "branch": "${SEMAPHORE_GIT_BRANCH}", "remote": "${SEMAPHORE_GIT_URL}", "revision": "${SEMAPHORE_GIT_SHA}", - "branch": "${SEMAPHORE_GIT_BRANCH}", "tag": "${SEMAPHORE_GIT_TAG_NAME}" - } + }, + "name": "Semaphore", + "url": "${SEMAPHORE_ORGANIZATION_URL}/jobs/${SEMAPHORE_JOB_ID}" }, { - "name": "Travis CI", - "url": "${TRAVIS_BUILD_WEB_URL}", "buildNumber": "${TRAVIS_JOB_NUMBER}", "git": { + "branch": "${TRAVIS_BRANCH}", "remote": "https://github.com/${TRAVIS_REPO_SLUG}.git", "revision": "${TRAVIS_COMMIT}", - "branch": "${TRAVIS_BRANCH}", "tag": "${TRAVIS_TAG}" - } + }, + "name": "Travis CI", + "url": "${TRAVIS_BUILD_WEB_URL}" }, { - "name": "Wercker", - "url": "${WERCKER_RUN_URL}", "buildNumber": "${WERCKER_RUN_URL/.*\\/([^\\/]+)$/\\1}", "git": { + "branch": "${WERCKER_GIT_BRANCH}", "remote": "https://${WERCKER_GIT_DOMAIN}/${WERCKER_GIT_OWNER}/${WERCKER_GIT_REPOSITORY}.git", - "revision": "${WERCKER_GIT_COMMIT}", - "branch": "${WERCKER_GIT_BRANCH}" - } + "revision": "${WERCKER_GIT_COMMIT}" + }, + "name": "Wercker", + "url": "${WERCKER_RUN_URL}" } ] diff --git a/go/Makefile b/go/Makefile index 6ff0aebb..5c2e6b7a 100644 --- a/go/Makefile +++ b/go/Makefile @@ -1,10 +1,17 @@ -copy-template: - cp ../CiEnvironments.json CiEnvironments.json - -test: copy-template - @echo "running all tests" - @go install ./... - @go fmt ./... - @go run honnef.co/go/tools/cmd/staticcheck@v0.3.2 github.com/cucumber/ci-environment/go - go vet ./... - go test ./... +SHELL := /usr/bin/env bash + +CI_ENVIRONMENTS_JSON = CiEnvironments.json + +help: ## Show this help + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \n\nWhere is one of:\n"} /^[$$()% a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) +.PHONY: help + +copy-ci-environment: $(CI_ENVIRONMENTS_JSON) ## Copy CiEnvironments.json and/or generate derived files +.PHONY: copy-ci-environment + +clean-ci-environment: ## Remove CiEnvironments.json and any derived files + rm -f $(GHERKIN_LANGUAGES_JSON) +.PHONY: clean-ci-environment + +$(CI_ENVIRONMENTS_JSON): + cp ../CiEnvironments.json $@ diff --git a/java/Makefile b/java/Makefile new file mode 100644 index 00000000..55274e7e --- /dev/null +++ b/java/Makefile @@ -0,0 +1,13 @@ +SHELL := /usr/bin/env bash + +help: ## Show this help + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \n\nWhere is one of:\n"} /^[$$()% a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) +.PHONY: help + +copy-ci-environment: ## Copy CiEnvironments.json and/or generate derived files + echo "Nothing to do" +.PHONY: copy-ci-environment + +clean-ci-environment: ## Remove CiEnvironments.json and any derived files + echo "Nothing to do" +.PHONY: clean-ci-environment diff --git a/javascript/Makefile b/javascript/Makefile new file mode 100644 index 00000000..55274e7e --- /dev/null +++ b/javascript/Makefile @@ -0,0 +1,13 @@ +SHELL := /usr/bin/env bash + +help: ## Show this help + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \n\nWhere is one of:\n"} /^[$$()% a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) +.PHONY: help + +copy-ci-environment: ## Copy CiEnvironments.json and/or generate derived files + echo "Nothing to do" +.PHONY: copy-ci-environment + +clean-ci-environment: ## Remove CiEnvironments.json and any derived files + echo "Nothing to do" +.PHONY: clean-ci-environment diff --git a/javascript/package.json b/javascript/package.json index f40987b1..5e0dac15 100644 --- a/javascript/package.json +++ b/javascript/package.json @@ -9,14 +9,14 @@ "dist" ], "scripts": { - "build": "tsc --project tsconfig.build.json", + "build": "npm run generate-ci-environments-ts && tsc --project tsconfig.build.json", "pretest": "npm run generate-ci-environments-ts", "test": "mocha", "prepublishOnly": "npm run build", "fix": "biome check --fix --error-on-warnings", "lint": "biome check --error-on-warnings", "postbuild": "node -e \"require('.')\"", - "generate-ci-environments-ts": "shx cat CiEnvironments.ts.header ../CiEnvironments.json > src/CiEnvironments.ts && biome check --fix --error-on-warnings src/CiEnvironments.ts" + "generate-ci-environments-ts": "shx cat CiEnvironments.ts.header ../CiEnvironments.json > src/CiEnvironments.ts && biome check --fix --error-on-warnings --vcs-use-ignore-file false src/CiEnvironments.ts" }, "repository": { "type": "git", diff --git a/javascript/src/.gitignore b/javascript/src/.gitignore new file mode 100644 index 00000000..eb555ef6 --- /dev/null +++ b/javascript/src/.gitignore @@ -0,0 +1 @@ +CiEnvironments.ts diff --git a/javascript/src/CiEnvironments.ts b/javascript/src/CiEnvironments.ts deleted file mode 100644 index cee3b22d..00000000 --- a/javascript/src/CiEnvironments.ts +++ /dev/null @@ -1,165 +0,0 @@ -/* This file is auto-generated using npm run build-ci-environments */ - -import type { CiEnvironment } from './types.js' - -export const CiEnvironments: readonly CiEnvironment[] = [ - { - buildNumber: '${BUILD_BUILDNUMBER}', - git: { - branch: '${BUILD_SOURCEBRANCH/refs/heads/(.*)/\\1}', - remote: '${BUILD_REPOSITORY_URI}', - revision: '${BUILD_SOURCEVERSION}', - tag: '${BUILD_SOURCEBRANCH/refs/tags/(.*)/\\1}', - }, - name: 'Azure Pipelines', - url: '${BUILD_BUILDURI}', - }, - { - buildNumber: '${bamboo_buildNumber}', - git: { - branch: '${bamboo_planRepository_branch}', - remote: '${bamboo_planRepository_repositoryUrl}', - revision: '${bamboo_planRepository_revision}', - }, - name: 'Bamboo', - url: '${bamboo_buildResultsUrl}', - }, - { - buildNumber: '${BUDDY_EXECUTION_ID}', - git: { - branch: '${BUDDY_EXECUTION_BRANCH}', - remote: '${BUDDY_SCM_URL}', - revision: '${BUDDY_EXECUTION_REVISION}', - tag: '${BUDDY_EXECUTION_TAG}', - }, - name: 'Buddy', - url: '${BUDDY_EXECUTION_URL}', - }, - { - buildNumber: '${BITRISE_BUILD_NUMBER}', - git: { - branch: '${BITRISE_GIT_BRANCH}', - remote: '${GIT_REPOSITORY_URL}', - revision: '${BITRISE_GIT_COMMIT}', - tag: '${BITRISE_GIT_TAG}', - }, - name: 'Bitrise', - url: '${BITRISE_BUILD_URL}', - }, - { - buildNumber: '${CIRCLE_BUILD_NUM}', - git: { - branch: '${CIRCLE_BRANCH}', - remote: '${CIRCLE_REPOSITORY_URL}', - revision: '${CIRCLE_SHA1}', - tag: '${CIRCLE_TAG}', - }, - name: 'CircleCI', - url: '${CIRCLE_BUILD_URL}', - }, - { - buildNumber: '${CF_BUILD_ID}', - git: { - branch: '${CF_BRANCH}', - remote: '${CF_COMMIT_URL/(.*)\\/commit.+$/\\1}.git', - revision: '${CF_REVISION}', - }, - name: 'CodeFresh', - url: '${CF_BUILD_URL}', - }, - { - buildNumber: '${CI_BUILD_NUMBER}', - git: { - branch: '${CI_BRANCH}', - remote: '${CI_PULL_REQUEST/(.*)\\/pull\\/\\d+/\\1.git}', - revision: '${CI_COMMIT_ID}', - }, - name: 'CodeShip', - url: '${CI_BUILD_URL}', - }, - { - buildNumber: '${GITHUB_RUN_ID}', - git: { - branch: '${GITHUB_HEAD_REF}', - remote: '${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git', - revision: '${GITHUB_SHA}', - tag: '${GITHUB_REF/refs/tags/(.*)/\\1}', - }, - name: 'GitHub Actions', - url: '${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}', - }, - { - buildNumber: '${CI_JOB_ID}', - git: { - branch: '${CI_COMMIT_BRANCH}', - remote: '${CI_REPOSITORY_URL}', - revision: '${CI_COMMIT_SHA}', - tag: '${CI_COMMIT_TAG}', - }, - name: 'GitLab', - url: '${CI_JOB_URL}', - }, - { - buildNumber: '${GO_PIPELINE_NAME}/${GO_PIPELINE_COUNTER}/${GO_STAGE_NAME}/${GO_STAGE_COUNTER}', - git: { - branch: '${GO_SCM_*_PR_BRANCH/.*:(.*)/\\1}', - remote: '${GO_SCM_*_PR_URL/(.*)\\/pull\\/\\d+/\\1.git}', - revision: '${GO_REVISION}', - }, - name: 'GoCD', - url: '${GO_SERVER_URL}/pipelines/${GO_PIPELINE_NAME}/${GO_PIPELINE_COUNTER}/${GO_STAGE_NAME}/${GO_STAGE_COUNTER}', - }, - { - buildNumber: '${BUILD_NUMBER}', - git: { - branch: '${GIT_LOCAL_BRANCH}', - remote: '${GIT_URL}', - revision: '${GIT_COMMIT}', - }, - name: 'Jenkins', - url: '${BUILD_URL}', - }, - { - buildNumber: '${JB_SPACE_EXECUTION_NUMBER}', - git: { - branch: '${JB_SPACE_GIT_BRANCH}', - remote: - 'https://${JB_SPACE_API_URL}/p/${JB_SPACE_PROJECT_KEY}/repositories/${JB_SPACE_GIT_REPOSITORY_NAME}', - revision: '${JB_SPACE_GIT_REVISION}', - }, - name: 'JetBrains Space', - url: '${JB_SPACE_EXECUTION_URL}', - }, - { - buildNumber: '${SEMAPHORE_JOB_ID}', - git: { - branch: '${SEMAPHORE_GIT_BRANCH}', - remote: '${SEMAPHORE_GIT_URL}', - revision: '${SEMAPHORE_GIT_SHA}', - tag: '${SEMAPHORE_GIT_TAG_NAME}', - }, - name: 'Semaphore', - url: '${SEMAPHORE_ORGANIZATION_URL}/jobs/${SEMAPHORE_JOB_ID}', - }, - { - buildNumber: '${TRAVIS_JOB_NUMBER}', - git: { - branch: '${TRAVIS_BRANCH}', - remote: 'https://github.com/${TRAVIS_REPO_SLUG}.git', - revision: '${TRAVIS_COMMIT}', - tag: '${TRAVIS_TAG}', - }, - name: 'Travis CI', - url: '${TRAVIS_BUILD_WEB_URL}', - }, - { - buildNumber: '${WERCKER_RUN_URL/.*\\/([^\\/]+)$/\\1}', - git: { - branch: '${WERCKER_GIT_BRANCH}', - remote: 'https://${WERCKER_GIT_DOMAIN}/${WERCKER_GIT_OWNER}/${WERCKER_GIT_REPOSITORY}.git', - revision: '${WERCKER_GIT_COMMIT}', - }, - name: 'Wercker', - url: '${WERCKER_RUN_URL}', - }, -] diff --git a/python/Makefile b/python/Makefile new file mode 100644 index 00000000..bc1408f2 --- /dev/null +++ b/python/Makefile @@ -0,0 +1,17 @@ +SHELL := /usr/bin/env bash + +CI_ENVIRONMENTS_JSON = src/ci_environment/CiEnvironments.json + +help: ## Show this help + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \n\nWhere is one of:\n"} /^[$$()% a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) +.PHONY: help + +copy-ci-environment: $(CI_ENVIRONMENTS_JSON) ## Copy CiEnvironments.json and/or generate derived files +.PHONY: copy-ci-environment + +clean-ci-environment: ## Remove CiEnvironments.json and any derived files + rm -f $(GHERKIN_LANGUAGES_JSON) +.PHONY: clean-ci-environment + +$(CI_ENVIRONMENTS_JSON): + cp ../CiEnvironments.json $@ diff --git a/python/src/ci_environment/CiEnvironments.json b/python/src/ci_environment/CiEnvironments.json index 639aeb34..58ee9c75 100644 --- a/python/src/ci_environment/CiEnvironments.json +++ b/python/src/ci_environment/CiEnvironments.json @@ -1,160 +1,160 @@ [ { - "name": "Azure Pipelines", - "url": "${BUILD_BUILDURI}", "buildNumber": "${BUILD_BUILDNUMBER}", "git": { + "branch": "${BUILD_SOURCEBRANCH/refs/heads/(.*)/\\1}", "remote": "${BUILD_REPOSITORY_URI}", "revision": "${BUILD_SOURCEVERSION}", - "branch": "${BUILD_SOURCEBRANCH/refs\/heads\/(.*)/\\1}", - "tag": "${BUILD_SOURCEBRANCH/refs\/tags\/(.*)/\\1}" - } + "tag": "${BUILD_SOURCEBRANCH/refs/tags/(.*)/\\1}" + }, + "name": "Azure Pipelines", + "url": "${BUILD_BUILDURI}" }, { - "name": "Bamboo", - "url": "${bamboo_buildResultsUrl}", "buildNumber": "${bamboo_buildNumber}", "git": { + "branch": "${bamboo_planRepository_branch}", "remote": "${bamboo_planRepository_repositoryUrl}", - "revision": "${bamboo_planRepository_revision}", - "branch": "${bamboo_planRepository_branch}" - } + "revision": "${bamboo_planRepository_revision}" + }, + "name": "Bamboo", + "url": "${bamboo_buildResultsUrl}" }, { - "name": "Buddy", - "url": "${BUDDY_EXECUTION_URL}", "buildNumber": "${BUDDY_EXECUTION_ID}", "git": { + "branch": "${BUDDY_EXECUTION_BRANCH}", "remote": "${BUDDY_SCM_URL}", "revision": "${BUDDY_EXECUTION_REVISION}", - "branch": "${BUDDY_EXECUTION_BRANCH}", "tag": "${BUDDY_EXECUTION_TAG}" - } + }, + "name": "Buddy", + "url": "${BUDDY_EXECUTION_URL}" }, { - "name": "Bitrise", - "url": "${BITRISE_BUILD_URL}", "buildNumber": "${BITRISE_BUILD_NUMBER}", "git": { + "branch": "${BITRISE_GIT_BRANCH}", "remote": "${GIT_REPOSITORY_URL}", "revision": "${BITRISE_GIT_COMMIT}", - "branch": "${BITRISE_GIT_BRANCH}", "tag": "${BITRISE_GIT_TAG}" - } + }, + "name": "Bitrise", + "url": "${BITRISE_BUILD_URL}" }, { - "name": "CircleCI", - "url": "${CIRCLE_BUILD_URL}", "buildNumber": "${CIRCLE_BUILD_NUM}", "git": { + "branch": "${CIRCLE_BRANCH}", "remote": "${CIRCLE_REPOSITORY_URL}", "revision": "${CIRCLE_SHA1}", - "branch": "${CIRCLE_BRANCH}", "tag": "${CIRCLE_TAG}" - } + }, + "name": "CircleCI", + "url": "${CIRCLE_BUILD_URL}" }, { - "name": "CodeFresh", - "url": "${CF_BUILD_URL}", "buildNumber": "${CF_BUILD_ID}", "git": { + "branch": "${CF_BRANCH}", "remote": "${CF_COMMIT_URL/(.*)\\/commit.+$/\\1}.git", - "revision": "${CF_REVISION}", - "branch": "${CF_BRANCH}" - } + "revision": "${CF_REVISION}" + }, + "name": "CodeFresh", + "url": "${CF_BUILD_URL}" }, { - "name": "CodeShip", - "url": "${CI_BUILD_URL}", "buildNumber": "${CI_BUILD_NUMBER}", "git": { + "branch": "${CI_BRANCH}", "remote": "${CI_PULL_REQUEST/(.*)\\/pull\\/\\d+/\\1.git}", - "revision": "${CI_COMMIT_ID}", - "branch": "${CI_BRANCH}" - } + "revision": "${CI_COMMIT_ID}" + }, + "name": "CodeShip", + "url": "${CI_BUILD_URL}" }, { - "name": "GitHub Actions", - "url": "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}", "buildNumber": "${GITHUB_RUN_ID}", "git": { + "branch": "${GITHUB_HEAD_REF}", "remote": "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git", "revision": "${GITHUB_SHA}", - "branch": "${GITHUB_HEAD_REF}", - "tag": "${GITHUB_REF/refs\/tags\/(.*)/\\1}" - } + "tag": "${GITHUB_REF/refs/tags/(.*)/\\1}" + }, + "name": "GitHub Actions", + "url": "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" }, { - "name": "GitLab", - "url": "${CI_JOB_URL}", "buildNumber": "${CI_JOB_ID}", "git": { + "branch": "${CI_COMMIT_BRANCH}", "remote": "${CI_REPOSITORY_URL}", "revision": "${CI_COMMIT_SHA}", - "branch": "${CI_COMMIT_BRANCH}", "tag": "${CI_COMMIT_TAG}" - } + }, + "name": "GitLab", + "url": "${CI_JOB_URL}" }, { - "name": "GoCD", - "url": "${GO_SERVER_URL}/pipelines/${GO_PIPELINE_NAME}/${GO_PIPELINE_COUNTER}/${GO_STAGE_NAME}/${GO_STAGE_COUNTER}", "buildNumber": "${GO_PIPELINE_NAME}/${GO_PIPELINE_COUNTER}/${GO_STAGE_NAME}/${GO_STAGE_COUNTER}", "git": { + "branch": "${GO_SCM_*_PR_BRANCH/.*:(.*)/\\1}", "remote": "${GO_SCM_*_PR_URL/(.*)\\/pull\\/\\d+/\\1.git}", - "revision": "${GO_REVISION}", - "branch": "${GO_SCM_*_PR_BRANCH/.*:(.*)/\\1}" - } + "revision": "${GO_REVISION}" + }, + "name": "GoCD", + "url": "${GO_SERVER_URL}/pipelines/${GO_PIPELINE_NAME}/${GO_PIPELINE_COUNTER}/${GO_STAGE_NAME}/${GO_STAGE_COUNTER}" }, { - "name": "Jenkins", - "url": "${BUILD_URL}", "buildNumber": "${BUILD_NUMBER}", "git": { + "branch": "${GIT_LOCAL_BRANCH}", "remote": "${GIT_URL}", - "revision": "${GIT_COMMIT}", - "branch": "${GIT_LOCAL_BRANCH}" - } + "revision": "${GIT_COMMIT}" + }, + "name": "Jenkins", + "url": "${BUILD_URL}" }, { - "name": "JetBrains Space", - "url": "${JB_SPACE_EXECUTION_URL}", "buildNumber": "${JB_SPACE_EXECUTION_NUMBER}", "git": { + "branch": "${JB_SPACE_GIT_BRANCH}", "remote": "https://${JB_SPACE_API_URL}/p/${JB_SPACE_PROJECT_KEY}/repositories/${JB_SPACE_GIT_REPOSITORY_NAME}", - "revision": "${JB_SPACE_GIT_REVISION}", - "branch": "${JB_SPACE_GIT_BRANCH}" - } + "revision": "${JB_SPACE_GIT_REVISION}" + }, + "name": "JetBrains Space", + "url": "${JB_SPACE_EXECUTION_URL}" }, { - "name": "Semaphore", - "url": "${SEMAPHORE_ORGANIZATION_URL}/jobs/${SEMAPHORE_JOB_ID}", "buildNumber": "${SEMAPHORE_JOB_ID}", "git": { + "branch": "${SEMAPHORE_GIT_BRANCH}", "remote": "${SEMAPHORE_GIT_URL}", "revision": "${SEMAPHORE_GIT_SHA}", - "branch": "${SEMAPHORE_GIT_BRANCH}", "tag": "${SEMAPHORE_GIT_TAG_NAME}" - } + }, + "name": "Semaphore", + "url": "${SEMAPHORE_ORGANIZATION_URL}/jobs/${SEMAPHORE_JOB_ID}" }, { - "name": "Travis CI", - "url": "${TRAVIS_BUILD_WEB_URL}", "buildNumber": "${TRAVIS_JOB_NUMBER}", "git": { + "branch": "${TRAVIS_BRANCH}", "remote": "https://github.com/${TRAVIS_REPO_SLUG}.git", "revision": "${TRAVIS_COMMIT}", - "branch": "${TRAVIS_BRANCH}", "tag": "${TRAVIS_TAG}" - } + }, + "name": "Travis CI", + "url": "${TRAVIS_BUILD_WEB_URL}" }, { - "name": "Wercker", - "url": "${WERCKER_RUN_URL}", "buildNumber": "${WERCKER_RUN_URL/.*\\/([^\\/]+)$/\\1}", "git": { + "branch": "${WERCKER_GIT_BRANCH}", "remote": "https://${WERCKER_GIT_DOMAIN}/${WERCKER_GIT_OWNER}/${WERCKER_GIT_REPOSITORY}.git", - "revision": "${WERCKER_GIT_COMMIT}", - "branch": "${WERCKER_GIT_BRANCH}" - } + "revision": "${WERCKER_GIT_COMMIT}" + }, + "name": "Wercker", + "url": "${WERCKER_RUN_URL}" } ] diff --git a/ruby/.gitignore b/ruby/.gitignore index 463c834f..7389eb7d 100644 --- a/ruby/.gitignore +++ b/ruby/.gitignore @@ -3,6 +3,5 @@ coverage/ pkg/ *.gem .compared -lib/cucumber/CiEnvironments.json *-go *.iml diff --git a/ruby/Makefile b/ruby/Makefile new file mode 100644 index 00000000..00c9634c --- /dev/null +++ b/ruby/Makefile @@ -0,0 +1,17 @@ +SHELL := /usr/bin/env bash + +CI_ENVIRONMENTS_JSON = lib/cucumber/CiEnvironments.json + +help: ## Show this help + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \n\nWhere is one of:\n"} /^[$$()% a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) +.PHONY: help + +copy-ci-environment: $(CI_ENVIRONMENTS_JSON) ## Copy CiEnvironments.json and/or generate derived files +.PHONY: copy-ci-environment + +clean-ci-environment: ## Remove CiEnvironments.json and any derived files + rm -f $(GHERKIN_LANGUAGES_JSON) +.PHONY: clean-ci-environment + +$(CI_ENVIRONMENTS_JSON): + cp ../CiEnvironments.json $@ diff --git a/ruby/Rakefile b/ruby/Rakefile index 6341b384..25caaefb 100644 --- a/ruby/Rakefile +++ b/ruby/Rakefile @@ -2,12 +2,7 @@ $LOAD_PATH.unshift(File.expand_path('lib', __dir__)) -file :ci_environments do - FileUtils.cp('../CiEnvironments.json', 'lib/cucumber/CiEnvironments.json') -end +require 'rspec/core/rake_task' +RSpec::Core::RakeTask.new(:spec) -desc 'Copy the sample environments & run all the unit tests for all environment types' -task spec: :ci_environments do - system('bundle exec rspec') -end task default: :spec diff --git a/ruby/lib/cucumber/CiEnvironments.json b/ruby/lib/cucumber/CiEnvironments.json new file mode 100644 index 00000000..58ee9c75 --- /dev/null +++ b/ruby/lib/cucumber/CiEnvironments.json @@ -0,0 +1,160 @@ +[ + { + "buildNumber": "${BUILD_BUILDNUMBER}", + "git": { + "branch": "${BUILD_SOURCEBRANCH/refs/heads/(.*)/\\1}", + "remote": "${BUILD_REPOSITORY_URI}", + "revision": "${BUILD_SOURCEVERSION}", + "tag": "${BUILD_SOURCEBRANCH/refs/tags/(.*)/\\1}" + }, + "name": "Azure Pipelines", + "url": "${BUILD_BUILDURI}" + }, + { + "buildNumber": "${bamboo_buildNumber}", + "git": { + "branch": "${bamboo_planRepository_branch}", + "remote": "${bamboo_planRepository_repositoryUrl}", + "revision": "${bamboo_planRepository_revision}" + }, + "name": "Bamboo", + "url": "${bamboo_buildResultsUrl}" + }, + { + "buildNumber": "${BUDDY_EXECUTION_ID}", + "git": { + "branch": "${BUDDY_EXECUTION_BRANCH}", + "remote": "${BUDDY_SCM_URL}", + "revision": "${BUDDY_EXECUTION_REVISION}", + "tag": "${BUDDY_EXECUTION_TAG}" + }, + "name": "Buddy", + "url": "${BUDDY_EXECUTION_URL}" + }, + { + "buildNumber": "${BITRISE_BUILD_NUMBER}", + "git": { + "branch": "${BITRISE_GIT_BRANCH}", + "remote": "${GIT_REPOSITORY_URL}", + "revision": "${BITRISE_GIT_COMMIT}", + "tag": "${BITRISE_GIT_TAG}" + }, + "name": "Bitrise", + "url": "${BITRISE_BUILD_URL}" + }, + { + "buildNumber": "${CIRCLE_BUILD_NUM}", + "git": { + "branch": "${CIRCLE_BRANCH}", + "remote": "${CIRCLE_REPOSITORY_URL}", + "revision": "${CIRCLE_SHA1}", + "tag": "${CIRCLE_TAG}" + }, + "name": "CircleCI", + "url": "${CIRCLE_BUILD_URL}" + }, + { + "buildNumber": "${CF_BUILD_ID}", + "git": { + "branch": "${CF_BRANCH}", + "remote": "${CF_COMMIT_URL/(.*)\\/commit.+$/\\1}.git", + "revision": "${CF_REVISION}" + }, + "name": "CodeFresh", + "url": "${CF_BUILD_URL}" + }, + { + "buildNumber": "${CI_BUILD_NUMBER}", + "git": { + "branch": "${CI_BRANCH}", + "remote": "${CI_PULL_REQUEST/(.*)\\/pull\\/\\d+/\\1.git}", + "revision": "${CI_COMMIT_ID}" + }, + "name": "CodeShip", + "url": "${CI_BUILD_URL}" + }, + { + "buildNumber": "${GITHUB_RUN_ID}", + "git": { + "branch": "${GITHUB_HEAD_REF}", + "remote": "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git", + "revision": "${GITHUB_SHA}", + "tag": "${GITHUB_REF/refs/tags/(.*)/\\1}" + }, + "name": "GitHub Actions", + "url": "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" + }, + { + "buildNumber": "${CI_JOB_ID}", + "git": { + "branch": "${CI_COMMIT_BRANCH}", + "remote": "${CI_REPOSITORY_URL}", + "revision": "${CI_COMMIT_SHA}", + "tag": "${CI_COMMIT_TAG}" + }, + "name": "GitLab", + "url": "${CI_JOB_URL}" + }, + { + "buildNumber": "${GO_PIPELINE_NAME}/${GO_PIPELINE_COUNTER}/${GO_STAGE_NAME}/${GO_STAGE_COUNTER}", + "git": { + "branch": "${GO_SCM_*_PR_BRANCH/.*:(.*)/\\1}", + "remote": "${GO_SCM_*_PR_URL/(.*)\\/pull\\/\\d+/\\1.git}", + "revision": "${GO_REVISION}" + }, + "name": "GoCD", + "url": "${GO_SERVER_URL}/pipelines/${GO_PIPELINE_NAME}/${GO_PIPELINE_COUNTER}/${GO_STAGE_NAME}/${GO_STAGE_COUNTER}" + }, + { + "buildNumber": "${BUILD_NUMBER}", + "git": { + "branch": "${GIT_LOCAL_BRANCH}", + "remote": "${GIT_URL}", + "revision": "${GIT_COMMIT}" + }, + "name": "Jenkins", + "url": "${BUILD_URL}" + }, + { + "buildNumber": "${JB_SPACE_EXECUTION_NUMBER}", + "git": { + "branch": "${JB_SPACE_GIT_BRANCH}", + "remote": "https://${JB_SPACE_API_URL}/p/${JB_SPACE_PROJECT_KEY}/repositories/${JB_SPACE_GIT_REPOSITORY_NAME}", + "revision": "${JB_SPACE_GIT_REVISION}" + }, + "name": "JetBrains Space", + "url": "${JB_SPACE_EXECUTION_URL}" + }, + { + "buildNumber": "${SEMAPHORE_JOB_ID}", + "git": { + "branch": "${SEMAPHORE_GIT_BRANCH}", + "remote": "${SEMAPHORE_GIT_URL}", + "revision": "${SEMAPHORE_GIT_SHA}", + "tag": "${SEMAPHORE_GIT_TAG_NAME}" + }, + "name": "Semaphore", + "url": "${SEMAPHORE_ORGANIZATION_URL}/jobs/${SEMAPHORE_JOB_ID}" + }, + { + "buildNumber": "${TRAVIS_JOB_NUMBER}", + "git": { + "branch": "${TRAVIS_BRANCH}", + "remote": "https://github.com/${TRAVIS_REPO_SLUG}.git", + "revision": "${TRAVIS_COMMIT}", + "tag": "${TRAVIS_TAG}" + }, + "name": "Travis CI", + "url": "${TRAVIS_BUILD_WEB_URL}" + }, + { + "buildNumber": "${WERCKER_RUN_URL/.*\\/([^\\/]+)$/\\1}", + "git": { + "branch": "${WERCKER_GIT_BRANCH}", + "remote": "https://${WERCKER_GIT_DOMAIN}/${WERCKER_GIT_OWNER}/${WERCKER_GIT_REPOSITORY}.git", + "revision": "${WERCKER_GIT_COMMIT}" + }, + "name": "Wercker", + "url": "${WERCKER_RUN_URL}" + } +] diff --git a/scripts/fail-if-dirty b/scripts/fail-if-dirty deleted file mode 100755 index e1c0845f..00000000 --- a/scripts/fail-if-dirty +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash -# This script fails if the git working copy is dirty, and prints the diff -set -e - -diff=$(git diff) -if [[ ! -z "${diff}" ]]; then - >&2 echo "The working copy is dirty:" - >&2 echo "${diff}" - exit 1 -fi