Skip to content

Commit

Permalink
Merge pull request #1 from maxim-lobanov/v-malob/implement-v1
Browse files Browse the repository at this point in the history
Implement the first version of action + caching support
  • Loading branch information
maxim-lobanov authored Sep 17, 2020
2 parents 02825f6 + bba4f44 commit 118c15f
Show file tree
Hide file tree
Showing 22 changed files with 63,929 additions and 2 deletions.
27 changes: 27 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"env": {
"node": true,
"es6": true,
"jest/globals": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:jest/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.eslint.json",
"ecmaVersion": 2018,
"sourceType": "module"
},
"plugins": ["@typescript-eslint", "jest"],
"ignorePatterns": ["node_modules/"],
"rules": {
"indent": ["error", 4],
"linebreak-style": ["error", "unix"],
"quotes": ["error", "double"],
"semi": ["error", "always"]
}
}
64 changes: 64 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Validate 'setup-android-tools'
on:
pull_request:
workflow_dispatch:
schedule:
- cron: 0 0 * * *

jobs:
task:
name: install
strategy:
matrix:
operating-system: [ubuntu-latest, windows-latest, macos-latest]
cache: [true, false]
fail-fast: false
runs-on: ${{ matrix.operating-system }}
steps:
- name: Checkout
uses: actions/checkout@v2

- name: setup ndk
uses: ./
with:
packages: ndk;19.2.5345600
cache: ${{ matrix.cache }}

- name: setup system-images
uses: ./
with:
packages: |
ndk-bundle
system-images;android-30;google_apis;x86
system-images;android-30;google_apis;x86_64
cache: ${{ matrix.cache }}

- name: setup components
uses: ./
with:
packages: |
add-ons;addon-google_apis-google-19
extras;m2repository;com;android;support;constraint;constraint-layout-solver;1.0.0-alpha8
extras;google;webdriver
cache: ${{ matrix.cache }}

already-installed:
name: pre-installed
strategy:
matrix:
operating-system: [ubuntu-latest, windows-latest, macos-latest]
fail-fast: false
runs-on: ${{ matrix.operating-system }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: setup platforms
uses: ./
with:
packages: |
platforms;android-29
platforms;android-30
- name: setup ndk-bundle
uses: ./
with:
packages: ndk-bundle
31 changes: 31 additions & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Build task
on: [pull_request]

jobs:
Build:
name: Build task
strategy:
matrix:
operating-system: [ubuntu-latest, macos-latest]
fail-fast: false
runs-on: ${{ matrix.operating-system }}
steps:
- name: Checkout
uses: actions/checkout@master

- name: Set Node.JS
uses: actions/setup-node@master
with:
node-version: 12.x

- name: npm install
run: npm install

- name: Build
run: npm run build

- name: Run tests
run: npm run test

- name: Lint
run: npm run lint
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
lib
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

The MIT License (MIT)

Copyright (c) 2020 Maxim Lobanov and contributors

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.
71 changes: 69 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,69 @@
# setup-android
Set up Android tools in GitHub Actions workflow with cache
# setup-android-tools
This action is intended to install Android tools on Hosted images in GitHub Actions.
It wraps `sdkmanager` and automates caching of installed packages.

### Usage
Install single package without cache:
```
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: setup-android-tools
uses: maxim-lobanov/[email protected]
with:
packages: ndk;19.2.5345600
```

Install multiple packages without cache:
```
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: maxim-lobanov/[email protected]
with:
packages: |
platforms;android-29
platforms;android-30
system-images;android-30;google_apis;x86
```

Install package with cache:
```
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: maxim-lobanov/[email protected]
with:
packages: ndk;19.2.5345600
cache: true
```

### Cache packages
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).

> **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.
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.

<details><summary>More details about speed advantage of using cache</summary>
<br>
(Table contains average results since installation time may vary depending on VM connection speed)

| Packages | OS | With cache (sec) | Without cache (sec) |
|-|-|-|-|
|ndk;19.2.5345600| Ubuntu | 62 | 85 |
| | Windows | 149 | 180 |
| | MacOS | 25 | 71 |
| ndk-bundle<br>system-images;android-30;google_apis;x86<br>system-images;android-30;google_apis;x86_64 | Ubuntu | 130 | 167 |
| | Windows | 157 | 182 |
| | MacOS | 43 | 205 |
| 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 |
| | Windows | 28 | 42 |
| | MacOS | 8 | 59 |
</details>


### License
The scripts and documentation in this project are released under the [MIT License](LICENSE)
92 changes: 92 additions & 0 deletions __tests__/fixture/complex-output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
Loading package information...
Loading local repository...
[========= ] 25% Loading local repository...
[========= ] 25% Fetch remote repository...
[========= ] 25% Fetch remote repository...
[============= ] 34% Fetch remote repository...
[================ ] 42% Fetch remote repository...

[================ ] 42% Fetch remote repository...
Warning: File C:\Users\runneradmin\.android\repositories.cfg could not be loaded.
[================= ] 43% Fetch remote repository...
[================== ] 46% Fetch remote repository...
[================== ] 47% Fetch remote repository...
[================== ] 47% Fetch remote repository...
[=================== ] 48% Fetch remote repository...
[=================== ] 49% Fetch remote repository...
[=================== ] 50% Fetch remote repository...
[==================== ] 50% Fetch remote repository...
[==================== ] 51% Fetch remote repository...
[==================== ] 52% Fetch remote repository...
[==================== ] 53% Fetch remote repository...
[===================== ] 53% Fetch remote repository...
[===================== ] 54% Fetch remote repository...
[===================== ] 55% Fetch remote repository...
[====================== ] 56% Fetch remote repository...
[====================== ] 56% Fetch remote repository...
[====================== ] 57% Fetch remote repository...
[======================= ] 58% Fetch remote repository...
[======================= ] 59% Fetch remote repository...
[======================= ] 59% Fetch remote repository...
[======================== ] 60% Fetch remote repository...
[======================== ] 60% Computing updates...
[============================= ] 75% Computing updates...
[============================= ] 75% Computing updates...
[=======================================] 100% Computing updates...
Installed packages:
Path | Version | Description | Location
------- | ------- | ------- | -------
add-ons;addon-google_apis-google-23 | 1 | Google APIs | add-ons\addon-google_apis-google-23\
add-ons;addon-google_apis-google-24 | 1 | Google APIs | add-ons\addon-google_apis-google-24\
build-tools;29.0.3 | 29.0.3 | Android SDK Build-Tools 29.0.3 | build-tools\29.0.3\
build-tools;30.0.0 | 30.0.0 | Android SDK Build-Tools 30 | build-tools\30.0.0\
cmake;3.10.2.4988404 | 3.10.2 | CMake 3.10.2.4988404 | cmake\3.10.2.4988404\
cmake;3.6.4111459 | 3.6.4111459 | CMake 3.6.4111459 | cmake\3.6.4111459\
extras;google;m2repository | 58 | Google Repository | extras\google\m2repository\
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\
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\
ndk-bundle | 21.3.6528147 | NDK | ndk-bundle\
patcher;v4 | 1 | SDK Patch Applier v4 | patcher\v4\
platform-tools | 30.0.4 | Android SDK Platform-Tools | platform-tools\
platforms;android-29 | 4 | Android SDK Platform 29 | platforms\android-29\
platforms;android-30 | 2 | Android SDK Platform 30 | platforms\android-30\
tools | 26.1.1 | Android SDK Tools 26.1.1 | tools\

Available Packages:
Path | Version | Description
------- | ------- | -------
add-ons;addon-google_apis-google-22 | 1 | Google APIs
add-ons;addon-google_apis-google-23 | 1 | Google APIs
add-ons;addon-google_apis-google-24 | 1 | Google APIs
build-tools;19.1.0 | 19.1.0 | Android SDK Build-Tools 19.1
build-tools;29.0.2 | 29.0.2 | Android SDK Build-Tools 29.0.2
build-tools;29.0.3 | 29.0.3 | Android SDK Build-Tools 29.0.3
build-tools;30.0.0 | 30.0.0 | Android SDK Build-Tools 30
build-tools;30.0.1 | 30.0.1 | Android SDK Build-Tools 30.0.1
cmake;3.10.2.4988404 | 3.10.2 | CMake 3.10.2.4988404
cmake;3.6.4111459 | 3.6.4111459 | CMake 3.6.4111459
cmdline-tools;latest | 2.1 | Android SDK Command-line Tools (latest)
emulator | 30.0.12 | Android Emulator
extras;google;m2repository | 58 | Google Repository
extras;intel;Hardware_Accelerated_Execution_Manager | 7.5.6 | Intel x86 Emulator Accelerator (HAXM installer)
extras;m2repository;com;android;support;constraint;constraint-layout-solver;1.0.1 | 1 | Solver for ConstraintLayout 1.0.1
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;1.0.1 | 1 | ConstraintLayout for Android 1.0.1
extras;m2repository;com;android;support;constraint;constraint-layout;1.0.2 | 1 | ConstraintLayout for Android 1.0.2
ndk-bundle | 21.4.6528148 | NDK
ndk;19.2.5345600 | 19.2.5345600 | NDK (Side by side) 19.2.5345600
ndk;21.2.6472646 | 21.2.6472646 | NDK (Side by side) 21.2.6472646
ndk;21.3.6528147 | 21.3.6528147 | NDK (Side by side) 21.3.6528147
patcher;v4 | 1 | SDK Patch Applier v4
platform-tools | 30.0.4 | Android SDK Platform-Tools
platforms;android-28 | 6 | Android SDK Platform 28
platforms;android-29 | 5 | Android SDK Platform 29
platforms;android-30 | 2 | Android SDK Platform 30
system-images;android-30;google_apis;x86 | 7 | Google APIs Intel x86 Atom System Image
system-images;android-30;google_apis;x86_64 | 7 | Google APIs Intel x86 Atom_64 System Image

Available Updates:
ID | Installed | Available
------- | ------- | -------
platforms;android-29 | 4 | 5
ndk-bundle | 21.3.6528147 | 21.4.6528148
18 changes: 18 additions & 0 deletions __tests__/fixture/package-update.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Loading package information...

Installed packages:
Path | Version | Description | Location
------- | ------- | ------- | -------
platforms;android-29 | 4 | Android Platform Tools 29 | platforms\\android-29\\
build-tools;28.0.2 | 28.0.2 | Android SDK Build-Tools 28.0.2 | build-tools\\28.0.2\\
Available Packages:
Path | Version | Description
------- | ------- | -------
ndk-bundle | 21.3.6528147 | NDK
platforms;android-29 | 5 | Android Platform Tools 29
build-tools;28.0.2 | 28.0.2 | Android SDK Build-Tools 28.0.2

Available Updates:
ID | Installed | Available
------- | ------- | -------
platforms;android-29 | 4 | 5
Loading

0 comments on commit 118c15f

Please sign in to comment.