Skip to content

Commit

Permalink
Initial version (#1)
Browse files Browse the repository at this point in the history
* initial commit

* initial commit

* updated ci workflow

* added test result exporting

* remove whitespaces

* removed whitespace

* PR changes
  • Loading branch information
trapacska authored Apr 4, 2018
1 parent e42cef2 commit 7c41a81
Show file tree
Hide file tree
Showing 37 changed files with 2,555 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.bitrise*
_tmp
43 changes: 43 additions & 0 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[[constraint]]
name = "github.com/bitrise-io/go-utils"
branch = "master"

[[constraint]]
name = "github.com/bitrise-tools/go-steputils"
branch = "master"

[prune]
go-tests = true
unused-packages = true
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2015 bitrise-steplib

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.
92 changes: 91 additions & 1 deletion README.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1 +1,91 @@
# bitrise-step-android-unit-test
# Android Unit Test

Runs your Android project's unit tests.

## 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
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 ;)
201 changes: 201 additions & 0 deletions bitrise.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
format_version: 5
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git

app:
envs:
- BITRISE_STEP_ID: android-unit-test
- BITRISE_STEP_VERSION: "0.9.0"
- BITRISE_STEP_GIT_CLONE_URL: https://github.com/bitrise-steplib/bitrise-step-android-unit-test.git
- MY_STEPLIB_REPO_FORK_GIT_URL: $MY_STEPLIB_REPO_FORK_GIT_URL
- SAMPLE_REPO_GIT_CLONE_URL: https://github.com/bitrise-samples/android-multiple-test-results-sample.git

workflows:
test:
title: Test simple android project & mono repo projects
before_run:
- audit-this-step
- go-tests
after_run:
- test-in-src-dir
- test-in-root-tmp-dir
- check-artifacts

test-in-src-dir:
title: Test android project & mono repo projects in source dir
steps:
- script:
inputs:
- content: rm -rf _tmp
- change-workdir:
title: cd $BITRISE_SOURCE_DIR/_tmp
run_if: true
inputs:
- path: ./_tmp
- is_create_path: true
- script:
inputs:
- content: git clone -b no-failures $SAMPLE_REPO_GIT_CLONE_URL .
- path::./:
title: Test simple android project

test-in-root-tmp-dir:
title: Test android project & mono repo projects in /tmp dir
steps:
- script:
inputs:
- content: rm -rf /tmp/_tmp
- change-workdir:
title: cd /tmp/_tmp
run_if: true
inputs:
- path: /tmp/_tmp
- is_create_path: true
- script:
inputs:
- content: git clone -b no-failures $SAMPLE_REPO_GIT_CLONE_URL .
- path::./:
title: Test simple repo

check-artifacts:
steps:
- script:
title: Check if files are existing
inputs:
- content: |-
#!/usr/bin/env bash
set -ex
# without timestamps
if [ ! -f $BITRISE_DEPLOY_DIR/another_app-reports.zip ]; then
exit 1
fi
if [ ! -f $BITRISE_DEPLOY_DIR/app-reports.zip ]; then
exit 1
fi
if [ ! -f $BITRISE_DEPLOY_DIR/another_app-test-results.zip ]; then
exit 1
fi
if [ ! -f $BITRISE_DEPLOY_DIR/app-test-results.zip ]; then
exit 1
fi
# with timestamps
if [ ! -f $(ls $BITRISE_DEPLOY_DIR/another_app-reports-20*.zip) ]; then
exit 1
fi
if [ ! -f $(ls $BITRISE_DEPLOY_DIR/app-reports-20*.zip) ]; then
exit 1
fi
if [ ! -f $(ls $BITRISE_DEPLOY_DIR/another_app-test-results-20*.zip) ]; then
exit 1
fi
if [ ! -f $(ls $BITRISE_DEPLOY_DIR/app-test-results-20*.zip) ]; then
exit 1
fi
go-tests:
steps:
- script:
title: Export go files to test
inputs:
- content: |-
#!/usr/bin/env bash
set -ex
no_vendor_paths="$(go list ./... | grep -v vendor)"
envman add --key GOLIST_WITHOUT_VENDOR --value "$no_vendor_paths"
- script:
title: Err check
inputs:
- content: |-
#!/usr/bin/env bash
set -ex
go get -u -v github.com/kisielk/errcheck
errcheck -asserts=true -blank=true $GOLIST_WITHOUT_VENDOR
- script:
title: Go lint
inputs:
- content: |-
#!/usr/bin/env bash
set -ex
go get -u -v github.com/golang/lint/golint
while read -r line; do
echo "-> Linting: $line"
golint_out="$(golint $line)"
if [[ "${golint_out}" != "" ]] ; then
echo "=> Golint issues found:"
echo "${golint_out}"
exit 1
fi
done <<< "$GOLIST_WITHOUT_VENDOR"
- script:
title: Go test
inputs:
- content: |-
#!/usr/bin/env bash
set -ex
go test ./...
# ----------------------------------------------------------------
# --- workflows to Share this step into a Step Library
audit-this-step:
steps:
- script:
inputs:
- content: |-
#!/usr/bin/env bash
set -ex
stepman audit --step-yml ./step.yml
# ----------------------------------------------------------------
# --- workflows to create Release
create-release:
steps:
- script:
title:
inputs:
- content: |
#!/usr/bin/env bash
set -e
export CI=true
releaseman create --version $BITRISE_STEP_VERSION
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: |-
#!/usr/bin/env 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
Loading

0 comments on commit 7c41a81

Please sign in to comment.