From eae6ed330bcabb72925a040e58fa1854347de777 Mon Sep 17 00:00:00 2001 From: Thomas Horta Date: Tue, 30 Nov 2021 23:49:21 -0300 Subject: [PATCH] initial commit with base template --- .gitignore | 2 ++ LICENSE | 21 +++++++++++ README.md | 93 ++++++++++++++++++++++++++++++++++++++++++++++++ bitrise.yml | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++ main.go | 31 ++++++++++++++++ step.yml | 87 +++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 334 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md create mode 100644 bitrise.yml create mode 100644 main.go create mode 100644 step.yml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a19bdb3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.bitrise* +.gows.user.yml diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..3be4f10 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2021 Thomas Horta + +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: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +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. diff --git a/README.md b/README.md new file mode 100644 index 0000000..93692d1 --- /dev/null +++ b/README.md @@ -0,0 +1,93 @@ +# JaCoCo Report Parser + +Fill description with what step does, services and tools used, configuration info, inputs, and troubleshooting. + + +## How to use this Step + +Can be run directly with the [bitrise CLI](https://github.com/bitrise-io/bitrise), +just `git clone` this repository, `cd` into it's folder in your Terminal/Command Line +and call `bitrise run test`. + +*Check the `bitrise.yml` file for required inputs which have to be +added to your `.bitrise.secrets.yml` file!* + +Step by step: + +1. Open up your Terminal / Command Line +2. `git clone` the repository +3. `cd` into the directory of the step (the one you just `git clone`d) +5. Create a `.bitrise.secrets.yml` file in the same directory of `bitrise.yml` + (the `.bitrise.secrets.yml` is a git ignored file, you can store your secrets in it) +6. Check the `bitrise.yml` file for any secret you should set in `.bitrise.secrets.yml` + * Best practice is to mark these options with something like `# define these in your .bitrise.secrets.yml`, in the `app:envs` section. +7. Once you have all the required secret parameters in your `.bitrise.secrets.yml` you can just run this step with the [bitrise CLI](https://github.com/bitrise-io/bitrise): `bitrise run test` + +An example `.bitrise.secrets.yml` file: + +``` +envs: +- A_SECRET_PARAM_ONE: the value for secret one +- A_SECRET_PARAM_TWO: the value for secret two +``` + +## How to create your own step + +1. Create a new git repository for your step (**don't fork** the *step template*, create a *new* repository) +2. Copy the [step template](https://github.com/bitrise-steplib/step-template) files into your repository +3. Fill the `step.sh` with your functionality +4. Wire out your inputs to `step.yml` (`inputs` section) +5. Fill out the other parts of the `step.yml` too +6. Provide test values for the inputs in the `bitrise.yml` +7. Run your step with `bitrise run test` - if it works, you're ready + +__For Step development guidelines & best practices__ check this documentation: [https://github.com/bitrise-io/bitrise/blob/master/_docs/step-development-guideline.md](https://github.com/bitrise-io/bitrise/blob/master/_docs/step-development-guideline.md). + +**NOTE:** + +If you want to use your step in your project's `bitrise.yml`: + +1. git push the step into it's repository +2. reference it in your `bitrise.yml` with the `git::PUBLIC-GIT-CLONE-URL@BRANCH` step reference style: + +``` +- git::https://github.com/user/my-step.git@branch: + title: My step + inputs: + - my_input_1: "my value 1" + - my_input_2: "my value 2" +``` + +You can find more examples of step reference styles +in the [bitrise CLI repository](https://github.com/bitrise-io/bitrise/blob/master/_examples/tutorials/steps-and-workflows/bitrise.yml#L65). + +## How to contribute to this Step + +1. Fork this repository +2. `git clone` it +3. Create a branch you'll work on +4. To use/test the step just follow the **How to use this Step** section +5. Do the changes you want to +6. Run/test the step before sending your contribution + * You can also test the step in your `bitrise` project, either on your Mac or on [bitrise.io](https://www.bitrise.io) + * You just have to replace the step ID in your project's `bitrise.yml` with either a relative path, or with a git URL format + * (relative) path format: instead of `- original-step-id:` use `- path::./relative/path/of/script/on/your/Mac:` + * direct git URL format: instead of `- original-step-id:` use `- git::https://github.com/user/step.git@branch:` + * You can find more example of alternative step referencing at: https://github.com/bitrise-io/bitrise/blob/master/_examples/tutorials/steps-and-workflows/bitrise.yml +7. Once you're done just commit your changes & create a Pull Request + + +## Share your own Step + +You can share your Step or step version with the [bitrise CLI](https://github.com/bitrise-io/bitrise). If you use the `bitrise.yml` included in this repository, all you have to do is: + +1. In your Terminal / Command Line `cd` into this directory (where the `bitrise.yml` of the step is located) +1. Run: `bitrise run test` to test the step +1. Run: `bitrise run audit-this-step` to audit the `step.yml` +1. Check the `share-this-step` workflow in the `bitrise.yml`, and fill out the + `envs` if you haven't done so already (don't forget to bump the version number if this is an update + of your step!) +1. Then run: `bitrise run share-this-step` to share the step (version) you specified in the `envs` +1. Send the Pull Request, as described in the logs of `bitrise run share-this-step` + +That's all ;) diff --git a/bitrise.yml b/bitrise.yml new file mode 100644 index 0000000..d1b9f23 --- /dev/null +++ b/bitrise.yml @@ -0,0 +1,100 @@ +format_version: 4 +default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git + +app: + envs: + # An example secret param, define it (A_SECRET_PARAM) in .bitrise.secrets.yml + - A_SECRET_PARAM: $A_SECRET_PARAM + # If you want to share this step into a StepLib + - BITRISE_STEP_ID: jacoco-report-parser + - BITRISE_STEP_VERSION: "0.0.1" + - BITRISE_STEP_GIT_CLONE_URL: https://github.com/thomashorta/bitrise-step-jacoco-report-parser.git + - MY_STEPLIB_REPO_FORK_GIT_URL: $MY_STEPLIB_REPO_FORK_GIT_URL + +workflows: + test: + steps: + - script: + inputs: + - content: | + #!/bin/bash + echo "Just an example 'secrets' print." + echo "The value of 'A_SECRET_PARAM' is: $A_SECRET_PARAM" + - change-workdir: + title: Switch working dir to test / _tmp dir + description: |- + To prevent step testing issues, like referencing relative + files with just './some-file' in the step's code, which would + work for testing the step from this directory directly + but would break if the step is included in another `bitrise.yml`. + run_if: true + inputs: + - path: ./_tmp + - is_create_path: true + - path::./: + title: Step Test + description: |- + The example input has a default value, + you can overwrite it if you want to, just like we did below, + but the step would use the default value specified in the `step.yml` + file if you would not specify another value. + run_if: true + inputs: + - example_step_input: Example Step Input's value + - script: + inputs: + - content: | + #!/bin/bash + echo "This output was generated by the Step (EXAMPLE_STEP_OUTPUT): $EXAMPLE_STEP_OUTPUT" + + + # ---------------------------------------------------------------- + # --- workflows to Share this step into a Step Library + audit-this-step: + steps: + - script: + inputs: + - content: |- + #!/bin/bash + set -ex + stepman audit --step-yml ./step.yml + + share-this-step: + envs: + # if you want to share this step into a StepLib + - MY_STEPLIB_REPO_FORK_GIT_URL: $MY_STEPLIB_REPO_FORK_GIT_URL + - BITRISE_STEP_ID: $BITRISE_STEP_ID + - BITRISE_STEP_VERSION: $BITRISE_STEP_VERSION + - BITRISE_STEP_GIT_CLONE_URL: $BITRISE_STEP_GIT_CLONE_URL + description: |- + If this is the first time you try to share a Step you should + first call: $ bitrise share + + This will print you a guide, and information about how Step sharing + works. Please read it at least once! + + As noted in the Step sharing guide you'll have to fork the + StepLib you want to share this step into. Once you're done with forking + the repository you should set your own fork's git clone URL + in the `.bitrise.secrets.yml` file, or here in the `envs` section, + as the value of the `MY_STEPLIB_REPO_FORK_GIT_URL` environment. + + You're now ready to share this Step, just make sure that + the `BITRISE_STEP_ID` and `BITRISE_STEP_VERSION` + environments are set to the desired values! + + To share this Step into a StepLib you can just run: $ bitrise run share-this-step + + Once it finishes the only thing left is to actually create a Pull Request, + the way described in the guide printed at the end of the process. + before_run: + - audit-this-step + steps: + - script: + inputs: + - content: |- + #!/bin/bash + set -ex + bitrise share start -c "${MY_STEPLIB_REPO_FORK_GIT_URL}" + bitrise share create --stepid "${BITRISE_STEP_ID}" --tag "${BITRISE_STEP_VERSION}" --git "${BITRISE_STEP_GIT_CLONE_URL}" + bitrise share finish diff --git a/main.go b/main.go new file mode 100644 index 0000000..5da5e2b --- /dev/null +++ b/main.go @@ -0,0 +1,31 @@ +package main + +import ( + "fmt" + "os" + "os/exec" +) + +func main() { + fmt.Println("This is the value specified for the input 'example_step_input':", os.Getenv("example_step_input")) + + // + // --- Step Outputs: Export Environment Variables for other Steps: + // You can export Environment Variables for other Steps with + // envman, which is automatically installed by `bitrise setup`. + // A very simple example: + cmdLog, err := exec.Command("bitrise", "envman", "add", "--key", "EXAMPLE_STEP_OUTPUT", "--value", "the value you want to share").CombinedOutput() + if err != nil { + fmt.Printf("Failed to expose output with envman, error: %#v | output: %s", err, cmdLog) + os.Exit(1) + } + // You can find more usage examples on envman's GitHub page + // at: https://github.com/bitrise-io/envman + + // + // --- Exit codes: + // The exit code of your Step is very important. If you return + // with a 0 exit code `bitrise` will register your Step as "successful". + // Any non zero exit code will be registered as "failed" by `bitrise`. + os.Exit(0) +} diff --git a/step.yml b/step.yml new file mode 100644 index 0000000..abcec15 --- /dev/null +++ b/step.yml @@ -0,0 +1,87 @@ +# +# A couple of useful guides & docs: +# +# - Main Bitrise CLI docs: https://github.com/bitrise-io/bitrise/tree/master/_docs +# - Step Development Guideline: https://github.com/bitrise-io/bitrise/blob/master/_docs/step-development-guideline.md +# - Bitrise.yml format spec: https://github.com/bitrise-io/bitrise/blob/master/_docs/bitrise-yml-format-spec.md +# - Bitrise docs: http://devcenter.bitrise.io/ +# - Bitrise CLI guides: http://devcenter.bitrise.io/bitrise-cli/ + +title: |- + JaCoCo Report Parser +summary: | + Parses a JaCoCo generated report and outputs the code coverage percentages to be used by other steps. +description: | + Fill description with what step does, services and tools used, configuration info, inputs, and troubleshooting. +website: https://github.com/thomashorta/bitrise-step-jacoco-report-parser +source_code_url: https://github.com/thomashorta/bitrise-step-jacoco-report-parser +support_url: https://github.com/thomashorta/bitrise-step-jacoco-report-parser/issues +host_os_tags: + - osx-10.10 + - ubuntu-16.04 + +# If this step should be available only for certain project types +# just uncomment this `project_type_tags` section and include all the +# project types supported by the step. If the step can be used for all +# project types then you can just remove this section. +# If no `project_type_tags` specified (or specified as an empty array) +# that means the step can be used for any project type. +# You can find more information about project type tags in the Step Development Guideline: +# https://github.com/bitrise-io/bitrise/blob/master/_docs/step-development-guideline.md +# +# project_type_tags: +# - ios +# - macos +# - android +# - xamarin +# - react-native +# - cordova +# - ionic + +# Type tags are used for categorizing steps, for easier step discovery in Step Libraries. +# You can find more information about type tags in the Step Development Guideline: +# https://github.com/bitrise-io/bitrise/blob/master/_docs/step-development-guideline.md +type_tags: + - test + +is_requires_admin_user: true +is_always_run: false +is_skippable: false +run_if: "" + +deps: + brew: + - name: git + - name: wget + apt_get: + - name: git + - name: wget + + +toolkit: + go: + package_name: github.com/thomashorta/bitrise-step-jacoco-report-parser + + +inputs: + - example_step_input: Default Value - you can leave this empty if you want to + opts: + title: "Example Step Input" + summary: Summary. No more than 2-3 sentences. + description: | + Description of this input. + + Can be Markdown formatted text. + is_expand: true + is_required: true + value_options: [] + +outputs: + - EXAMPLE_STEP_OUTPUT: + opts: + title: "Example Step Output" + summary: Summary. No more than 2-3 sentences. + description: | + Description of this output. + + Can be Markdown formatted text.