Skip to content

Commit 7c41a81

Browse files
authored
Initial version (bitrise-steplib#1)
* initial commit * initial commit * updated ci workflow * added test result exporting * remove whitespaces * removed whitespace * PR changes
1 parent e42cef2 commit 7c41a81

37 files changed

+2555
-1
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.bitrise*
2+
_tmp

Gopkg.lock

+43
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[[constraint]]
2+
name = "github.com/bitrise-io/go-utils"
3+
branch = "master"
4+
5+
[[constraint]]
6+
name = "github.com/bitrise-tools/go-steputils"
7+
branch = "master"
8+
9+
[prune]
10+
go-tests = true
11+
unused-packages = true

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 bitrise-steplib
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

100644100755
+91-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,91 @@
1-
# bitrise-step-android-unit-test
1+
# Android Unit Test
2+
3+
Runs your Android project's unit tests.
4+
5+
## How to use this Step
6+
7+
Can be run directly with the [bitrise CLI](https://github.com/bitrise-io/bitrise),
8+
just `git clone` this repository, `cd` into it's folder in your Terminal/Command Line
9+
and call `bitrise run test`.
10+
11+
*Check the `bitrise.yml` file for required inputs which have to be
12+
added to your `.bitrise.secrets.yml` file!*
13+
14+
Step by step:
15+
16+
1. Open up your Terminal / Command Line
17+
2. `git clone` the repository
18+
3. `cd` into the directory of the step (the one you just `git clone`d)
19+
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
20+
6. Check the `bitrise.yml` file for any secret you should set in `.bitrise.secrets.yml`
21+
* Best practice is to mark these options with something like `# define these in your .bitrise.secrets.yml`, in the `app:envs` section.
22+
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`
23+
24+
An example `.bitrise.secrets.yml` file:
25+
26+
```
27+
envs:
28+
- A_SECRET_PARAM_ONE: the value for secret one
29+
- A_SECRET_PARAM_TWO: the value for secret two
30+
```
31+
32+
## How to create your own step
33+
34+
1. Create a new git repository for your step (**don't fork** the *step template*, create a *new* repository)
35+
2. Copy the [step template](https://github.com/bitrise-steplib/step-template) files into your repository
36+
3. Fill the `step.sh` with your functionality
37+
4. Wire out your inputs to `step.yml` (`inputs` section)
38+
5. Fill out the other parts of the `step.yml` too
39+
6. Provide test values for the inputs in the `bitrise.yml`
40+
7. Run your step with `bitrise run test` - if it works, you're ready
41+
42+
__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).
43+
44+
**NOTE:**
45+
46+
If you want to use your step in your project's `bitrise.yml`:
47+
48+
1. git push the step into it's repository
49+
2. reference it in your `bitrise.yml` with the `git::PUBLIC-GIT-CLONE-URL@BRANCH` step reference style:
50+
51+
```
52+
- git::https://github.com/user/my-step.git@branch:
53+
title: My step
54+
inputs:
55+
- my_input_1: "my value 1"
56+
- my_input_2: "my value 2"
57+
```
58+
59+
You can find more examples of step reference styles
60+
in the [bitrise CLI repository](https://github.com/bitrise-io/bitrise/blob/master/_examples/tutorials/steps-and-workflows/bitrise.yml#L65).
61+
62+
## How to contribute to this Step
63+
64+
1. Fork this repository
65+
2. `git clone` it
66+
3. Create a branch you'll work on
67+
4. To use/test the step just follow the **How to use this Step** section
68+
5. Do the changes you want to
69+
6. Run/test the step before sending your contribution
70+
* You can also test the step in your `bitrise` project, either on your Mac or on [bitrise.io](https://www.bitrise.io)
71+
* 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
72+
* (relative) path format: instead of `- original-step-id:` use `- path::./relative/path/of/script/on/your/Mac:`
73+
* direct git URL format: instead of `- original-step-id:` use `- git::https://github.com/user/step.git@branch:`
74+
* 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
75+
7. Once you're done just commit your changes & create a Pull Request
76+
77+
78+
## Share your own Step
79+
80+
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:
81+
82+
1. In your Terminal / Command Line `cd` into this directory (where the `bitrise.yml` of the step is located)
83+
1. Run: `bitrise run test` to test the step
84+
1. Run: `bitrise run audit-this-step` to audit the `step.yml`
85+
1. Check the `share-this-step` workflow in the `bitrise.yml`, and fill out the
86+
`envs` if you haven't done so already (don't forget to bump the version number if this is an update
87+
of your step!)
88+
1. Then run: `bitrise run share-this-step` to share the step (version) you specified in the `envs`
89+
1. Send the Pull Request, as described in the logs of `bitrise run share-this-step`
90+
91+
That's all ;)

bitrise.yml

+201
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
format_version: 5
2+
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
3+
4+
app:
5+
envs:
6+
- BITRISE_STEP_ID: android-unit-test
7+
- BITRISE_STEP_VERSION: "0.9.0"
8+
- BITRISE_STEP_GIT_CLONE_URL: https://github.com/bitrise-steplib/bitrise-step-android-unit-test.git
9+
- MY_STEPLIB_REPO_FORK_GIT_URL: $MY_STEPLIB_REPO_FORK_GIT_URL
10+
- SAMPLE_REPO_GIT_CLONE_URL: https://github.com/bitrise-samples/android-multiple-test-results-sample.git
11+
12+
workflows:
13+
test:
14+
title: Test simple android project & mono repo projects
15+
before_run:
16+
- audit-this-step
17+
- go-tests
18+
after_run:
19+
- test-in-src-dir
20+
- test-in-root-tmp-dir
21+
- check-artifacts
22+
23+
test-in-src-dir:
24+
title: Test android project & mono repo projects in source dir
25+
steps:
26+
- script:
27+
inputs:
28+
- content: rm -rf _tmp
29+
- change-workdir:
30+
title: cd $BITRISE_SOURCE_DIR/_tmp
31+
run_if: true
32+
inputs:
33+
- path: ./_tmp
34+
- is_create_path: true
35+
- script:
36+
inputs:
37+
- content: git clone -b no-failures $SAMPLE_REPO_GIT_CLONE_URL .
38+
- path::./:
39+
title: Test simple android project
40+
41+
test-in-root-tmp-dir:
42+
title: Test android project & mono repo projects in /tmp dir
43+
steps:
44+
- script:
45+
inputs:
46+
- content: rm -rf /tmp/_tmp
47+
- change-workdir:
48+
title: cd /tmp/_tmp
49+
run_if: true
50+
inputs:
51+
- path: /tmp/_tmp
52+
- is_create_path: true
53+
- script:
54+
inputs:
55+
- content: git clone -b no-failures $SAMPLE_REPO_GIT_CLONE_URL .
56+
- path::./:
57+
title: Test simple repo
58+
59+
check-artifacts:
60+
steps:
61+
- script:
62+
title: Check if files are existing
63+
inputs:
64+
- content: |-
65+
#!/usr/bin/env bash
66+
set -ex
67+
68+
# without timestamps
69+
if [ ! -f $BITRISE_DEPLOY_DIR/another_app-reports.zip ]; then
70+
exit 1
71+
fi
72+
if [ ! -f $BITRISE_DEPLOY_DIR/app-reports.zip ]; then
73+
exit 1
74+
fi
75+
if [ ! -f $BITRISE_DEPLOY_DIR/another_app-test-results.zip ]; then
76+
exit 1
77+
fi
78+
if [ ! -f $BITRISE_DEPLOY_DIR/app-test-results.zip ]; then
79+
exit 1
80+
fi
81+
82+
# with timestamps
83+
if [ ! -f $(ls $BITRISE_DEPLOY_DIR/another_app-reports-20*.zip) ]; then
84+
exit 1
85+
fi
86+
if [ ! -f $(ls $BITRISE_DEPLOY_DIR/app-reports-20*.zip) ]; then
87+
exit 1
88+
fi
89+
if [ ! -f $(ls $BITRISE_DEPLOY_DIR/another_app-test-results-20*.zip) ]; then
90+
exit 1
91+
fi
92+
if [ ! -f $(ls $BITRISE_DEPLOY_DIR/app-test-results-20*.zip) ]; then
93+
exit 1
94+
fi
95+
96+
go-tests:
97+
steps:
98+
- script:
99+
title: Export go files to test
100+
inputs:
101+
- content: |-
102+
#!/usr/bin/env bash
103+
set -ex
104+
105+
no_vendor_paths="$(go list ./... | grep -v vendor)"
106+
envman add --key GOLIST_WITHOUT_VENDOR --value "$no_vendor_paths"
107+
- script:
108+
title: Err check
109+
inputs:
110+
- content: |-
111+
#!/usr/bin/env bash
112+
set -ex
113+
go get -u -v github.com/kisielk/errcheck
114+
errcheck -asserts=true -blank=true $GOLIST_WITHOUT_VENDOR
115+
- script:
116+
title: Go lint
117+
inputs:
118+
- content: |-
119+
#!/usr/bin/env bash
120+
set -ex
121+
go get -u -v github.com/golang/lint/golint
122+
while read -r line; do
123+
echo "-> Linting: $line"
124+
golint_out="$(golint $line)"
125+
if [[ "${golint_out}" != "" ]] ; then
126+
echo "=> Golint issues found:"
127+
echo "${golint_out}"
128+
exit 1
129+
fi
130+
done <<< "$GOLIST_WITHOUT_VENDOR"
131+
- script:
132+
title: Go test
133+
inputs:
134+
- content: |-
135+
#!/usr/bin/env bash
136+
set -ex
137+
go test ./...
138+
139+
# ----------------------------------------------------------------
140+
# --- workflows to Share this step into a Step Library
141+
audit-this-step:
142+
steps:
143+
- script:
144+
inputs:
145+
- content: |-
146+
#!/usr/bin/env bash
147+
set -ex
148+
stepman audit --step-yml ./step.yml
149+
150+
# ----------------------------------------------------------------
151+
# --- workflows to create Release
152+
create-release:
153+
steps:
154+
- script:
155+
title:
156+
inputs:
157+
- content: |
158+
#!/usr/bin/env bash
159+
set -e
160+
export CI=true
161+
releaseman create --version $BITRISE_STEP_VERSION
162+
163+
share-this-step:
164+
envs:
165+
# if you want to share this step into a StepLib
166+
- MY_STEPLIB_REPO_FORK_GIT_URL: $MY_STEPLIB_REPO_FORK_GIT_URL
167+
- BITRISE_STEP_ID: $BITRISE_STEP_ID
168+
- BITRISE_STEP_VERSION: $BITRISE_STEP_VERSION
169+
- BITRISE_STEP_GIT_CLONE_URL: $BITRISE_STEP_GIT_CLONE_URL
170+
description: |-
171+
If this is the first time you try to share a Step you should
172+
first call: $ bitrise share
173+
174+
This will print you a guide, and information about how Step sharing
175+
works. Please read it at least once!
176+
177+
As noted in the Step sharing guide you'll have to fork the
178+
StepLib you want to share this step into. Once you're done with forking
179+
the repository you should set your own fork's git clone URL
180+
in the `.bitrise.secrets.yml` file, or here in the `envs` section,
181+
as the value of the `MY_STEPLIB_REPO_FORK_GIT_URL` environment.
182+
183+
You're now ready to share this Step, just make sure that
184+
the `BITRISE_STEP_ID` and `BITRISE_STEP_VERSION`
185+
environments are set to the desired values!
186+
187+
To share this Step into a StepLib you can just run: $ bitrise run share-this-step
188+
189+
Once it finishes the only thing left is to actually create a Pull Request,
190+
the way described in the guide printed at the end of the process.
191+
before_run:
192+
- audit-this-step
193+
steps:
194+
- script:
195+
inputs:
196+
- content: |-
197+
#!/usr/bin/env bash
198+
set -ex
199+
bitrise share start -c "${MY_STEPLIB_REPO_FORK_GIT_URL}"
200+
bitrise share create --stepid "${BITRISE_STEP_ID}" --tag "${BITRISE_STEP_VERSION}" --git "${BITRISE_STEP_GIT_CLONE_URL}"
201+
bitrise share finish

0 commit comments

Comments
 (0)