Skip to content

Commit 118c15f

Browse files
Merge pull request #1 from maxim-lobanov/v-malob/implement-v1
Implement the first version of action + caching support
2 parents 02825f6 + bba4f44 commit 118c15f

22 files changed

+63929
-2
lines changed

.eslintrc.json

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"env": {
3+
"node": true,
4+
"es6": true,
5+
"jest/globals": true
6+
},
7+
"extends": [
8+
"eslint:recommended",
9+
"plugin:@typescript-eslint/eslint-recommended",
10+
"plugin:@typescript-eslint/recommended",
11+
"plugin:jest/recommended"
12+
],
13+
"parser": "@typescript-eslint/parser",
14+
"parserOptions": {
15+
"project": "./tsconfig.eslint.json",
16+
"ecmaVersion": 2018,
17+
"sourceType": "module"
18+
},
19+
"plugins": ["@typescript-eslint", "jest"],
20+
"ignorePatterns": ["node_modules/"],
21+
"rules": {
22+
"indent": ["error", 4],
23+
"linebreak-style": ["error", "unix"],
24+
"quotes": ["error", "double"],
25+
"semi": ["error", "always"]
26+
}
27+
}

.github/workflows/test.yml

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Validate 'setup-android-tools'
2+
on:
3+
pull_request:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: 0 0 * * *
7+
8+
jobs:
9+
task:
10+
name: install
11+
strategy:
12+
matrix:
13+
operating-system: [ubuntu-latest, windows-latest, macos-latest]
14+
cache: [true, false]
15+
fail-fast: false
16+
runs-on: ${{ matrix.operating-system }}
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v2
20+
21+
- name: setup ndk
22+
uses: ./
23+
with:
24+
packages: ndk;19.2.5345600
25+
cache: ${{ matrix.cache }}
26+
27+
- name: setup system-images
28+
uses: ./
29+
with:
30+
packages: |
31+
ndk-bundle
32+
system-images;android-30;google_apis;x86
33+
system-images;android-30;google_apis;x86_64
34+
cache: ${{ matrix.cache }}
35+
36+
- name: setup components
37+
uses: ./
38+
with:
39+
packages: |
40+
add-ons;addon-google_apis-google-19
41+
extras;m2repository;com;android;support;constraint;constraint-layout-solver;1.0.0-alpha8
42+
extras;google;webdriver
43+
cache: ${{ matrix.cache }}
44+
45+
already-installed:
46+
name: pre-installed
47+
strategy:
48+
matrix:
49+
operating-system: [ubuntu-latest, windows-latest, macos-latest]
50+
fail-fast: false
51+
runs-on: ${{ matrix.operating-system }}
52+
steps:
53+
- name: Checkout
54+
uses: actions/checkout@v2
55+
- name: setup platforms
56+
uses: ./
57+
with:
58+
packages: |
59+
platforms;android-29
60+
platforms;android-30
61+
- name: setup ndk-bundle
62+
uses: ./
63+
with:
64+
packages: ndk-bundle

.github/workflows/workflow.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Build task
2+
on: [pull_request]
3+
4+
jobs:
5+
Build:
6+
name: Build task
7+
strategy:
8+
matrix:
9+
operating-system: [ubuntu-latest, macos-latest]
10+
fail-fast: false
11+
runs-on: ${{ matrix.operating-system }}
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@master
15+
16+
- name: Set Node.JS
17+
uses: actions/setup-node@master
18+
with:
19+
node-version: 12.x
20+
21+
- name: npm install
22+
run: npm install
23+
24+
- name: Build
25+
run: npm run build
26+
27+
- name: Run tests
28+
run: npm run test
29+
30+
- name: Lint
31+
run: npm run lint

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+
lib

LICENSE

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

README.md

+69-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,69 @@
1-
# setup-android
2-
Set up Android tools in GitHub Actions workflow with cache
1+
# setup-android-tools
2+
This action is intended to install Android tools on Hosted images in GitHub Actions.
3+
It wraps `sdkmanager` and automates caching of installed packages.
4+
5+
### Usage
6+
Install single package without cache:
7+
```
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: setup-android-tools
13+
uses: maxim-lobanov/[email protected]
14+
with:
15+
packages: ndk;19.2.5345600
16+
```
17+
18+
Install multiple packages without cache:
19+
```
20+
jobs:
21+
build:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: maxim-lobanov/[email protected]
25+
with:
26+
packages: |
27+
platforms;android-29
28+
platforms;android-30
29+
system-images;android-30;google_apis;x86
30+
```
31+
32+
Install package with cache:
33+
```
34+
jobs:
35+
build:
36+
runs-on: ubuntu-latest
37+
steps:
38+
- uses: maxim-lobanov/[email protected]
39+
with:
40+
packages: ndk;19.2.5345600
41+
cache: true
42+
```
43+
44+
### Cache packages
45+
With `cache: true`, action will automatically cache all downloaded packages via [@actions/cache](https://github.com/actions/toolkit/tree/main/packages/cache). In some cases, it could significantly speed up your builds (especially on MacOS images).
46+
47+
> **Note:** GitHub will remove any cache entries that have not been accessed in over 7 days. There is no limit on the number of caches you can store, but the total size of all caches in a repository is limited to 5 GB. If you exceed this limit, GitHub will save your cache but will begin evicting caches until the total size is less than 5 GB.
48+
See "[Caching dependencies to speed up workflows](https://help.github.com/github/automating-your-workflow-with-github-actions/caching-dependencies-to-speed-up-workflows)" for how caching works.
49+
50+
<details><summary>More details about speed advantage of using cache</summary>
51+
<br>
52+
(Table contains average results since installation time may vary depending on VM connection speed)
53+
54+
| Packages | OS | With cache (sec) | Without cache (sec) |
55+
|-|-|-|-|
56+
|ndk;19.2.5345600| Ubuntu | 62 | 85 |
57+
| | Windows | 149 | 180 |
58+
| | MacOS | 25 | 71 |
59+
| ndk-bundle<br>system-images;android-30;google_apis;x86<br>system-images;android-30;google_apis;x86_64 | Ubuntu | 130 | 167 |
60+
| | Windows | 157 | 182 |
61+
| | MacOS | 43 | 205 |
62+
| platforms;android-20<br>add-ons;addon-google_apis-google-20<br>constraint-layout-solver;1.0.0-alpha8<br>extras;google;webdriver | Ubuntu | 10 | 20 |
63+
| | Windows | 28 | 42 |
64+
| | MacOS | 8 | 59 |
65+
</details>
66+
67+
68+
### License
69+
The scripts and documentation in this project are released under the [MIT License](LICENSE)

__tests__/fixture/complex-output.txt

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
Loading package information...
2+
Loading local repository...
3+
[========= ] 25% Loading local repository...
4+
[========= ] 25% Fetch remote repository...
5+
[========= ] 25% Fetch remote repository...
6+
[============= ] 34% Fetch remote repository...
7+
[================ ] 42% Fetch remote repository...
8+
9+
[================ ] 42% Fetch remote repository...
10+
Warning: File C:\Users\runneradmin\.android\repositories.cfg could not be loaded.
11+
[================= ] 43% Fetch remote repository...
12+
[================== ] 46% Fetch remote repository...
13+
[================== ] 47% Fetch remote repository...
14+
[================== ] 47% Fetch remote repository...
15+
[=================== ] 48% Fetch remote repository...
16+
[=================== ] 49% Fetch remote repository...
17+
[=================== ] 50% Fetch remote repository...
18+
[==================== ] 50% Fetch remote repository...
19+
[==================== ] 51% Fetch remote repository...
20+
[==================== ] 52% Fetch remote repository...
21+
[==================== ] 53% Fetch remote repository...
22+
[===================== ] 53% Fetch remote repository...
23+
[===================== ] 54% Fetch remote repository...
24+
[===================== ] 55% Fetch remote repository...
25+
[====================== ] 56% Fetch remote repository...
26+
[====================== ] 56% Fetch remote repository...
27+
[====================== ] 57% Fetch remote repository...
28+
[======================= ] 58% Fetch remote repository...
29+
[======================= ] 59% Fetch remote repository...
30+
[======================= ] 59% Fetch remote repository...
31+
[======================== ] 60% Fetch remote repository...
32+
[======================== ] 60% Computing updates...
33+
[============================= ] 75% Computing updates...
34+
[============================= ] 75% Computing updates...
35+
[=======================================] 100% Computing updates...
36+
Installed packages:
37+
Path | Version | Description | Location
38+
------- | ------- | ------- | -------
39+
add-ons;addon-google_apis-google-23 | 1 | Google APIs | add-ons\addon-google_apis-google-23\
40+
add-ons;addon-google_apis-google-24 | 1 | Google APIs | add-ons\addon-google_apis-google-24\
41+
build-tools;29.0.3 | 29.0.3 | Android SDK Build-Tools 29.0.3 | build-tools\29.0.3\
42+
build-tools;30.0.0 | 30.0.0 | Android SDK Build-Tools 30 | build-tools\30.0.0\
43+
cmake;3.10.2.4988404 | 3.10.2 | CMake 3.10.2.4988404 | cmake\3.10.2.4988404\
44+
cmake;3.6.4111459 | 3.6.4111459 | CMake 3.6.4111459 | cmake\3.6.4111459\
45+
extras;google;m2repository | 58 | Google Repository | extras\google\m2repository\
46+
extras;m2repository;com;android;support;constraint;constraint-layout-solver;1.0.2 | 1 | Solver for ConstraintLayout 1.0.2 | extras\m2repository\com\android\support\constraint\constraint-layout-solver\1.0.2\
47+
extras;m2repository;com;android;support;constraint;constraint-layout;1.0.2 | 1 | ConstraintLayout for Android 1.0.2 | extras\m2repository\com\android\support\constraint\constraint-layout\1.0.2\
48+
ndk-bundle | 21.3.6528147 | NDK | ndk-bundle\
49+
patcher;v4 | 1 | SDK Patch Applier v4 | patcher\v4\
50+
platform-tools | 30.0.4 | Android SDK Platform-Tools | platform-tools\
51+
platforms;android-29 | 4 | Android SDK Platform 29 | platforms\android-29\
52+
platforms;android-30 | 2 | Android SDK Platform 30 | platforms\android-30\
53+
tools | 26.1.1 | Android SDK Tools 26.1.1 | tools\
54+
55+
Available Packages:
56+
Path | Version | Description
57+
------- | ------- | -------
58+
add-ons;addon-google_apis-google-22 | 1 | Google APIs
59+
add-ons;addon-google_apis-google-23 | 1 | Google APIs
60+
add-ons;addon-google_apis-google-24 | 1 | Google APIs
61+
build-tools;19.1.0 | 19.1.0 | Android SDK Build-Tools 19.1
62+
build-tools;29.0.2 | 29.0.2 | Android SDK Build-Tools 29.0.2
63+
build-tools;29.0.3 | 29.0.3 | Android SDK Build-Tools 29.0.3
64+
build-tools;30.0.0 | 30.0.0 | Android SDK Build-Tools 30
65+
build-tools;30.0.1 | 30.0.1 | Android SDK Build-Tools 30.0.1
66+
cmake;3.10.2.4988404 | 3.10.2 | CMake 3.10.2.4988404
67+
cmake;3.6.4111459 | 3.6.4111459 | CMake 3.6.4111459
68+
cmdline-tools;latest | 2.1 | Android SDK Command-line Tools (latest)
69+
emulator | 30.0.12 | Android Emulator
70+
extras;google;m2repository | 58 | Google Repository
71+
extras;intel;Hardware_Accelerated_Execution_Manager | 7.5.6 | Intel x86 Emulator Accelerator (HAXM installer)
72+
extras;m2repository;com;android;support;constraint;constraint-layout-solver;1.0.1 | 1 | Solver for ConstraintLayout 1.0.1
73+
extras;m2repository;com;android;support;constraint;constraint-layout-solver;1.0.2 | 1 | Solver for ConstraintLayout 1.0.2
74+
extras;m2repository;com;android;support;constraint;constraint-layout;1.0.1 | 1 | ConstraintLayout for Android 1.0.1
75+
extras;m2repository;com;android;support;constraint;constraint-layout;1.0.2 | 1 | ConstraintLayout for Android 1.0.2
76+
ndk-bundle | 21.4.6528148 | NDK
77+
ndk;19.2.5345600 | 19.2.5345600 | NDK (Side by side) 19.2.5345600
78+
ndk;21.2.6472646 | 21.2.6472646 | NDK (Side by side) 21.2.6472646
79+
ndk;21.3.6528147 | 21.3.6528147 | NDK (Side by side) 21.3.6528147
80+
patcher;v4 | 1 | SDK Patch Applier v4
81+
platform-tools | 30.0.4 | Android SDK Platform-Tools
82+
platforms;android-28 | 6 | Android SDK Platform 28
83+
platforms;android-29 | 5 | Android SDK Platform 29
84+
platforms;android-30 | 2 | Android SDK Platform 30
85+
system-images;android-30;google_apis;x86 | 7 | Google APIs Intel x86 Atom System Image
86+
system-images;android-30;google_apis;x86_64 | 7 | Google APIs Intel x86 Atom_64 System Image
87+
88+
Available Updates:
89+
ID | Installed | Available
90+
------- | ------- | -------
91+
platforms;android-29 | 4 | 5
92+
ndk-bundle | 21.3.6528147 | 21.4.6528148

__tests__/fixture/package-update.txt

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Loading package information...
2+
3+
Installed packages:
4+
Path | Version | Description | Location
5+
------- | ------- | ------- | -------
6+
platforms;android-29 | 4 | Android Platform Tools 29 | platforms\\android-29\\
7+
build-tools;28.0.2 | 28.0.2 | Android SDK Build-Tools 28.0.2 | build-tools\\28.0.2\\
8+
Available Packages:
9+
Path | Version | Description
10+
------- | ------- | -------
11+
ndk-bundle | 21.3.6528147 | NDK
12+
platforms;android-29 | 5 | Android Platform Tools 29
13+
build-tools;28.0.2 | 28.0.2 | Android SDK Build-Tools 28.0.2
14+
15+
Available Updates:
16+
ID | Installed | Available
17+
------- | ------- | -------
18+
platforms;android-29 | 4 | 5

0 commit comments

Comments
 (0)