Compare commits

...
45 Commits
Author SHA1 Message Date
semantic-release-bot c3c02de017 chore: create new release 6.0.0
## [6.0.0](https://github.com/expo/expo-github-action/compare/5.5.1...6.0.0) (2021-06-22)

### ⚠ BREAKING CHANGES

* Github Action inputs are changed to allow both Expo and EAS CLI.

### New features

* add support for eas cli installs ([#98](https://github.com/expo/expo-github-action/issues/98)) ([04692c3](https://github.com/expo/expo-github-action/commit/04692c3cb1f7ad977f62841ca0bb175c903f653f))

### Other chores

* update node to 14 and 16 in ci ([#100](https://github.com/expo/expo-github-action/issues/100)) ([a03876e](https://github.com/expo/expo-github-action/commit/a03876e3c556bea147f2be007eac911bf78c9b23))

### Documentation changes

* add commands to contirbuting guide for updating v{major} tags ([1b57c37](https://github.com/expo/expo-github-action/commit/1b57c37e9bdfe92e183befb3595debc64da672f0))
* update readme for v6 release ([#101](https://github.com/expo/expo-github-action/issues/101)) ([8b43bae](https://github.com/expo/expo-github-action/commit/8b43bae073f280d4fa76aa174642ad46febe985c))
* update upstream reference in contributing guide ([76ce4de](https://github.com/expo/expo-github-action/commit/76ce4de80ea89b343404cdabadc922882af80487))
2021-06-22 14:32:09 +00:00
Cedric van Putten 8b43bae073 docs: update readme for v6 release (#101)
* docs: update readme for v6 release

* docs: update all master references to main

* docs: update references to v6

* docs: fix link to eas build example
2021-06-22 16:27:07 +02:00
Cedric van Putten a03876e3c5 chore: update node to 14 and 16 in ci (#100) 2021-06-22 15:30:18 +02:00
Cedric van Putten 04692c3cb1 feature!: add support for eas cli installs (#98)
* feature!: add support for eas cli installs

* refactor: update the action metadata

* docs: update documentation to include eas examples

* fix: breaking change detection for semantic release

* docs: add notion about latest eas version

BREAKING CHANGE: Github Action inputs are changed to allow both Expo and EAS CLI.
2021-06-22 14:48:17 +02:00
Cedric van Putten 1b57c37e9b docs: add commands to contirbuting guide for updating v{major} tags 2021-06-17 14:13:56 +02:00
Cedric van Putten 76ce4de80e docs: update upstream reference in contributing guide 2021-06-17 14:11:07 +02:00
semantic-release-bot a888e4f311 chore: create new release 5.5.1
### [5.5.1](https://github.com/expo/expo-github-action/compare/5.5.0...5.5.1) (2021-06-17)

### Bug fixes

* revert to node 12 for the action ([2662a5f](https://github.com/expo/expo-github-action/commit/2662a5f0dec42d7a9c66b55f8ce937f37aaac9b4))
2021-06-17 12:00:20 +00:00
Cedric van Putten 2662a5f0de fix: revert to node 12 for the action 2021-06-17 13:58:51 +02:00
semantic-release-bot d4dc05e178 chore: create new release 5.5.0
## [5.5.0](https://github.com/expo/expo-github-action/compare/5.4.0...5.5.0) (2021-06-17)

### New features

* switch to node 14 for the action itself ([f13b0ea](https://github.com/expo/expo-github-action/commit/f13b0ea032efcf2e6689743879af6b3e1c72201d))

### Bug fixes

* add support for environments without remote cache ([#91](https://github.com/expo/expo-github-action/issues/91)) ([9c0e696](https://github.com/expo/expo-github-action/commit/9c0e6962510d4e08c6429cac42f624c563675ee1))

### Code changes

* simplify typescript config with community config ([#94](https://github.com/expo/expo-github-action/issues/94)) ([da4e754](https://github.com/expo/expo-github-action/commit/da4e75428b7c5ffd16e8b2c698f590313c741621))
* update all dependencies to latest versions ([#93](https://github.com/expo/expo-github-action/issues/93)) ([6bc0bed](https://github.com/expo/expo-github-action/commit/6bc0bedbc75bb0d6743e4accf032cd01348d6775))

### Other chores

* add semantic release for easy versioning ([#95](https://github.com/expo/expo-github-action/issues/95)) ([6354b0a](https://github.com/expo/expo-github-action/commit/6354b0a0477a72375cee808d8a5b6006d6e86e77))
* fix the allowed branches for semenatic release ([6b8c488](https://github.com/expo/expo-github-action/commit/6b8c488fd6239c9a76d7f95355a58bc8b2a20ac4))
* mock the github actions warning to avoid leaking annotations ([#96](https://github.com/expo/expo-github-action/issues/96)) ([a11a47a](https://github.com/expo/expo-github-action/commit/a11a47a3e8735a206eed196499604322b0bdc877))
* tweak the release workflow ([79ebfbc](https://github.com/expo/expo-github-action/commit/79ebfbc3b83497f443fd65eb5bd33484e5519f64))

### Documentation changes

* add missing release step to contributing guide ([04e3b32](https://github.com/expo/expo-github-action/commit/04e3b32e94e3abe9cd65d37c57a0cead55186970))
2021-06-17 11:56:00 +00:00
Cedric van Putten 04e3b32e94 docs: add missing release step to contributing guide 2021-06-17 13:48:41 +02:00
Cedric van Putten a11a47a3e8 chore: mock the github actions warning to avoid leaking annotations (#96) 2021-06-17 13:45:18 +02:00
Cedric van Putten 79ebfbc3b8 chore: tweak the release workflow
It should be able to publish from master and main, plus checks if the build is up to date
2021-06-17 13:36:09 +02:00
Cedric van Putten 6b8c488fd6 chore: fix the allowed branches for semenatic release 2021-06-17 13:30:48 +02:00
Cedric van Putten f13b0ea032 feature: switch to node 14 for the action itself
Although this isn't a big feature, it does include new features from Node.
2021-06-17 13:27:07 +02:00
Cedric van Putten 6354b0a047 chore: add semantic release for easy versioning (#95)
* chore: add semantic release for easy versioning

* chore: add workflow to release a new version

* docs: add contributing guide for developers
2021-06-17 13:22:35 +02:00
Cedric van Putten da4e75428b refactor: simplify typescript config with community config (#94) 2021-06-17 13:05:01 +02:00
Cedric van Putten 6bc0bedbc7 refactor: update all dependencies to latest versions (#93)
* refactor: update actions cache to 1.0.7

- Make caching more verbose
- Use GNU tar on macOS if available
- Fixes permissions issue extracting archives with GNU tar on macOS

* refactor: update actions core to 1.4.0

- Prepend newline for set-output
- Added the getBooleanInput function
- Added the trimWhitespace option to getInput
- Added the getMultilineInput function

* refactor: update actions exec to 1.1.0

- Better error for bad cwd
- Add getExecOutput function
- Fix stdline dropping large output

* refactor: update actions io to 1.1.1

- Add findInPath method to locate all matching executables in the system path
- Fixed a bug where we incorrectly escaped paths for rmrf

* refactor: update actions tool-cache to 1.7.1

- Force overwrite on default when extracted compressed files
- Export isExplicitVersion and evaluateVersions functions
- Allow arbirtary headers when downloading tools to the tc
- Update to latest @actions/io verison
- Fallback to os-releases file to get linux version

* refactor: update jest to 27

* refactor: update node types to 14.17.3

* refactor: update semver and types to latest version

* refactor: update typescript to latest version

* refactor: update eslint to latest version

* refactor: update husky to 6.0.0

* chore: rebuild yarn lockfile and build files
2021-06-17 12:51:22 +02:00
Cedric van Putten 9c0e696251 fix: add support for environments without remote cache (#91) 2021-06-17 00:48:00 +02:00
Cedric van Putten 8275e8fa89 chore: release version 5.4.0 2021-01-12 15:20:04 +01:00
Cedric van Putten 4ec7251759 chore: update all dependencies to latest versions (#78) 2021-01-12 14:43:14 +01:00
Cedric van Putten 6c0f4d78ba chore: update readme to latest expo cli and node (#77) 2021-01-12 14:40:35 +01:00
Cedric van Putten 917e072b54 refactor: improve error handling with update check (#76) 2021-01-12 14:32:44 +01:00
Cedric van Putten ed7f67d90e refactor: update all dev dependencies to latest version (#71)
* refactor: use node 14 as primary version to build from

* refactor: add explicit return types to all files

* refactor: update all dev dependencies to latest version

* refactor: update strict typings in test utils
2020-12-04 19:52:01 +01:00
Cedric van Putten 13d78207a1 docs: update the cache description without the fork 2020-12-04 19:29:33 +01:00
Cedric van Putten 75b743cff5 refactor: group output by steps for readability (#70) 2020-12-04 19:20:56 +01:00
Cedric van Putten 187c4adfcc refactor: output cache errors with actions core 2020-12-04 17:10:23 +01:00
Matthew Ondash 0eb46e97d7 refactor: use official actions cache package instead of cypress fork (#62)
* Now uses official @actions/cache package

* Run yarn upgrade

* Add handling for ReserveCacheError (#1)

Bump @actions/cache from 1.0.2 to 1.0.3
Add missing caret to specify @actions/cache version range
Add handling for ReserveCacheError
2020-12-04 16:16:20 +01:00
Cedric van Putten 5d3c1cdff4 chore: release version 5.3.1 2020-10-20 18:08:45 +02:00
Cedric van Putten ce1c6b612a chore: rebuilt the project after dependency bump 2020-10-02 15:17:31 +02:00
dependabot[bot] b807fa603f chore: bump @actions/core from 1.2.4 to 1.2.6 (#63)
Bumps [@actions/core](https://github.com/actions/toolkit/tree/HEAD/packages/core) from 1.2.4 to 1.2.6.
- [Release notes](https://github.com/actions/toolkit/releases)
- [Changelog](https://github.com/actions/toolkit/blob/main/packages/core/RELEASES.md)
- [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/core)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-10-02 15:12:54 +02:00
Cedric van Putten 1010edb8c8 chore: release version 5.3.0 2020-09-19 03:57:01 +02:00
Cedric van Putten b80de3494e fix: rebuild full project with ncc 2020-09-19 03:50:47 +02:00
Cedric van Putten f773f9c85c chore: clean up outdated expo test 2020-08-28 17:14:35 +02:00
Cedric van Putten 1c36889886 feat: add expo token authentication method (#57) 2020-08-28 17:12:37 +02:00
Cedric van Putten ce3c32e185 chore: release new version 5.2.0 2020-07-14 16:04:39 +02:00
Cedric van Putten 050b7019f7 docs: update build badge in readme (#56) 2020-07-14 15:35:43 +02:00
Cedric van Putten 404bd09c6f chore: upgrade all dependencies to latest version (#55) 2020-07-14 15:30:19 +02:00
Cedric van Putten d3602b92b2 refactor: use github actions instead of circle (#54)
* refactor: use github actions instead of circle

* fix: only check outdated build on node 12

* refactor: replace paths in tests with join for windows

* refactor: change expo binary tests when logging in

* refactor: replace paths in tests with join for windows

* chore: only support current and future lts in ci

* chore: remove circle ci configuration

* fix: remove windows from up to date check
2020-07-14 15:13:30 +02:00
Paul Cowgill 6ac67f03d0 docs: fix grammar and link in readme
* Grammar fix

* Fix cache info link in README

* Use working link to point to original section
2020-07-10 20:19:43 +02:00
Darsh Shah b8a49f4d14 fix: proper space between icon and text (#50) 2020-06-14 01:38:10 +02:00
Cedric van Putten 84e06132b2 chore: release new version 5.1.1 2020-06-10 19:28:03 +02:00
Brad Bumbalough 71dfeab7a0 fix: use inputs metadata key (#49) 2020-06-10 19:23:27 +02:00
Cedric van Putten f6dba4e7ce docs: fix typo in secrets link 2020-05-11 11:09:34 +02:00
Cedric van Putten 586d2b1bea docs: tweak the license to make it identifyable 2020-05-11 09:44:02 +02:00
Cedric van Putten 39cd204496 docs: refine the readme and update header style (#48)
* docs: update footer with a better design

* docs: refine some of the documentation
2020-05-09 22:42:25 +02:00
35 changed files with 149648 additions and 57645 deletions

No files matched your search

-51
View File
@@ -1,51 +0,0 @@
---
version: 2
scripts: &scripts
steps:
- checkout
- run: yarn
- run: yarn test
- run: yarn lint
- run: yarn build
uptodate: &uptodate
steps:
- checkout
- run: yarn
- run: yarn build
- run: git diff --exit-code build
jobs:
node-10:
<<: *scripts
docker:
- image: circleci/node:10
node-12:
<<: *scripts
docker:
- image: circleci/node:12
node-13:
<<: *scripts
docker:
- image: circleci/node:13
node-14:
<<: *scripts
docker:
- image: circleci/node:14
uptodate:
<<: *uptodate
requires:
- node-12
docker:
- image: circleci/node:12
workflows:
version: 2
build:
jobs:
- node-10
- node-12
- node-13
- node-14
- uptodate
+12 -10
View File
@@ -1,15 +1,15 @@
module.exports = {
parser: '@typescript-eslint/parser',
plugins: [
'@typescript-eslint',
parser: '@typescript-eslint/parser',
plugins: [
'@typescript-eslint',
'jest',
],
env: {
es6: true,
'jest/globals': true,
node: true,
},
extends: [
],
env: {
es6: true,
'jest/globals': true,
node: true,
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
],
@@ -18,8 +18,10 @@ module.exports = {
'@typescript-eslint/explicit-member-accessibility': [
'error', { 'accessibility': 'no-public' },
],
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/indent': ['error', 'tab'],
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
};
+55
View File
@@ -0,0 +1,55 @@
---
name: CI
on:
push:
branches: [master]
pull_request:
types: [opened, synchronize]
jobs:
build:
name: Test and build
runs-on: ${{ matrix.os }}
strategy:
matrix:
node: [14, 16]
os:
- macos-latest
- ubuntu-latest
- windows-latest
include:
- node: 14
os: macos-latest
checkUpToDate: true
- node: 14
os: ubuntu-latest
checkUpToDate: true
steps:
- name: Setup repo
uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- name: Find cache
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Restore cache
uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: yarn install --frozen-lockfile --check-files
- name: Lint package
run: yarn lint
- name: Test package
run: yarn test
- name: Build clean
run: yarn clean
- name: Build package
run: yarn build
- name: Build up-to-date
if: ${{ matrix.checkUpToDate }}
run: git diff --stat --exit-code build
+51
View File
@@ -0,0 +1,51 @@
---
name: Release
on:
workflow_dispatch:
inputs:
release:
description: 'type "release" to confirm creating a new release (main branch only)'
required: false
jobs:
release:
name: Release version
runs-on: ubuntu-latest
steps:
- name: Setup repo
uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v1
with:
node-version: 14.x
- name: Find cache
id: yarn-cache-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Restore cache
uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: yarn install --frozen-lockfile --check-files
- name: Lint package
run: yarn lint
- name: Test package
run: yarn test
- name: Build clean
run: yarn clean
- name: Build package
run: yarn build
- name: Build up-to-date
run: git diff --stat --exit-code build
- name: Test-run release
if: success() && github.event.inputs.release != 'release'
run: yarn semantic-release --dry-run
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create release
if: success() && github.event.inputs.release == 'release' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
run: yarn semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+1
View File
@@ -0,0 +1 @@
_
+5
View File
@@ -0,0 +1,5 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
yarn build
git add build
+8
View File
@@ -0,0 +1,8 @@
{
"printWidth": 120,
"tabWidth": 2,
"singleQuote": true,
"jsxBracketSameLine": true,
"trailingComma": "es5",
"arrowParens": "avoid"
}
+43
View File
@@ -0,0 +1,43 @@
const rules = [
{ type: 'feat', release: 'minor', title: 'New features' },
{ type: 'feature', release: 'minor', title: 'New features' },
{ type: 'fix', release: 'patch', title: 'Bug fixes' },
{ type: 'refactor', release: 'patch', title: 'Code changes' },
{ type: 'chore', release: 'patch', title: 'Other chores' },
{ type: 'docs', release: 'patch', title: 'Documentation changes' },
];
// Simple mapping to order the commit groups
const sortMap = Object.fromEntries(rules.map((rule, index) => [rule.title, index]));
module.exports = {
branches: ['main', 'master'],
tagFormat: '${version}',
plugins: [
['@semantic-release/commit-analyzer', {
preset: 'conventionalcommits',
releaseRules: [
{ breaking: true, release: 'major' },
{ revert: true, release: 'patch' },
].concat(
rules.map(({ type, release, breaking }) => ({ type, release, breaking }))
),
}],
['@semantic-release/release-notes-generator', {
preset: 'conventionalcommits',
presetConfig: {
types: rules.map(({ type, title }) => ({ type, section: title })),
},
writerOpts: {
commitGroupsSort: (a, z) => sortMap[a.title] - sortMap[z.title],
},
}],
'@semantic-release/changelog',
['@semantic-release/npm', { npmPublish: false }],
['@semantic-release/git', {
message: 'chore: create new release ${nextRelease.version}\n\n${nextRelease.notes}',
assets: ['package.json', 'CHANGELOG.md'],
}],
'@semantic-release/github',
],
};
+125
View File
@@ -1,3 +1,128 @@
## [6.0.0](https://github.com/expo/expo-github-action/compare/5.5.1...6.0.0) (2021-06-22)
### ⚠ BREAKING CHANGES
* Github Action inputs are changed to allow both Expo and EAS CLI.
### New features
* add support for eas cli installs ([#98](https://github.com/expo/expo-github-action/issues/98)) ([04692c3](https://github.com/expo/expo-github-action/commit/04692c3cb1f7ad977f62841ca0bb175c903f653f))
### Other chores
* update node to 14 and 16 in ci ([#100](https://github.com/expo/expo-github-action/issues/100)) ([a03876e](https://github.com/expo/expo-github-action/commit/a03876e3c556bea147f2be007eac911bf78c9b23))
### Documentation changes
* add commands to contirbuting guide for updating v{major} tags ([1b57c37](https://github.com/expo/expo-github-action/commit/1b57c37e9bdfe92e183befb3595debc64da672f0))
* update readme for v6 release ([#101](https://github.com/expo/expo-github-action/issues/101)) ([8b43bae](https://github.com/expo/expo-github-action/commit/8b43bae073f280d4fa76aa174642ad46febe985c))
* update upstream reference in contributing guide ([76ce4de](https://github.com/expo/expo-github-action/commit/76ce4de80ea89b343404cdabadc922882af80487))
### [5.5.1](https://github.com/expo/expo-github-action/compare/5.5.0...5.5.1) (2021-06-17)
### Bug fixes
* revert to node 12 for the action ([2662a5f](https://github.com/expo/expo-github-action/commit/2662a5f0dec42d7a9c66b55f8ce937f37aaac9b4))
## [5.5.0](https://github.com/expo/expo-github-action/compare/5.4.0...5.5.0) (2021-06-17)
### New features
* switch to node 14 for the action itself ([f13b0ea](https://github.com/expo/expo-github-action/commit/f13b0ea032efcf2e6689743879af6b3e1c72201d))
### Bug fixes
* add support for environments without remote cache ([#91](https://github.com/expo/expo-github-action/issues/91)) ([9c0e696](https://github.com/expo/expo-github-action/commit/9c0e6962510d4e08c6429cac42f624c563675ee1))
### Code changes
* simplify typescript config with community config ([#94](https://github.com/expo/expo-github-action/issues/94)) ([da4e754](https://github.com/expo/expo-github-action/commit/da4e75428b7c5ffd16e8b2c698f590313c741621))
* update all dependencies to latest versions ([#93](https://github.com/expo/expo-github-action/issues/93)) ([6bc0bed](https://github.com/expo/expo-github-action/commit/6bc0bedbc75bb0d6743e4accf032cd01348d6775))
### Other chores
* add semantic release for easy versioning ([#95](https://github.com/expo/expo-github-action/issues/95)) ([6354b0a](https://github.com/expo/expo-github-action/commit/6354b0a0477a72375cee808d8a5b6006d6e86e77))
* fix the allowed branches for semenatic release ([6b8c488](https://github.com/expo/expo-github-action/commit/6b8c488fd6239c9a76d7f95355a58bc8b2a20ac4))
* mock the github actions warning to avoid leaking annotations ([#96](https://github.com/expo/expo-github-action/issues/96)) ([a11a47a](https://github.com/expo/expo-github-action/commit/a11a47a3e8735a206eed196499604322b0bdc877))
* tweak the release workflow ([79ebfbc](https://github.com/expo/expo-github-action/commit/79ebfbc3b83497f443fd65eb5bd33484e5519f64))
### Documentation changes
* add missing release step to contributing guide ([04e3b32](https://github.com/expo/expo-github-action/commit/04e3b32e94e3abe9cd65d37c57a0cead55186970))
## [5.4.0](https://github.com/expo/expo-github-action/compare/5.3.1...5.4.0) (2021-01-12)
### New features
* improve error handling with update check ([#76](https://github.com/expo/expo-github-action/pull/76)) ([917e072](https://github.com/expo/expo-github-action/commit/917e072))
### Code refactors
* use official actions cache package instead of cypress fork ([#62](https://github.com/expo/expo-github-action/pull/62)) ([0eb46e9](https://github.com/expo/expo-github-action/commit/0eb46e9))
* output cache errors with actions core ([187c4ad](https://github.com/expo/expo-github-action/commit/187c4ad))
* group output by steps for readability ([#70](https://github.com/expo/expo-github-action/pull/70)) ([75b743c](https://github.com/expo/expo-github-action/commit/75b743c))
* update all dev dependencies to latest version ([#71](https://github.com/expo/expo-github-action/pull/71)) ([ed7f67d](https://github.com/expo/expo-github-action/commit/ed7f67d))
### Documentation changes
* update the cache description without the fork ([13d7820](https://github.com/expo/expo-github-action/commit/13d7820))
* update readme to latest expo cli and node ([#77](https://github.com/expo/expo-github-action/pull/77)) ([6c0f4d7](https://github.com/expo/expo-github-action/commit/6c0f4d7))
### Other chores
* update all dependencies to latest versions ([#78](https://github.com/expo/expo-github-action/pull/78)) ([4ec7251](https://github.com/expo/expo-github-action/commit/4ec7251))
## [5.3.1](https://github.com/expo/expo-github-action/compare/5.3.0...5.3.1) (2020-10-20)
### Other chores
* bump @actions/core from 1.2.4 to 1.2.6 ([#63](https://github.com/expo/expo-github-action/pull/63)) ([b807fa6](https://github.com/expo/expo-github-action/commit/b807fa6))
## [5.3.0](https://github.com/expo/expo-github-action/compare/5.2.0...5.3.0) (2020-09-19)
### New features
* add expo token authentication method ([#57](https://github.com/expo/expo-github-action/pull/57)) ([1c36889](https://github.com/expo/expo-github-action/commit/1c36889))
## [5.2.0](https://github.com/expo/expo-github-action/compare/5.1.1...5.2.0) (2020-07-14)
### Bug fixes
* proper space between icon and text ([#50](https://github.com/expo/expo-github-action/pull/50)) ([b8a49f4](https://github.com/expo/expo-github-action/commit/b8a49f4))
### Code refactors
* use github actions instead of circle ([#54](https://github.com/expo/expo-github-action/pull/54)) ([d3602b9](https://github.com/expo/expo-github-action/commit/d3602b9))
### Documentation changes
* fix grammar and link in readme ([#53](https://github.com/expo/expo-github-action/pull/53)) ([6ac67f0](https://github.com/expo/expo-github-action/commit/6ac67f0))
* update build badge in readme ([#56](https://github.com/expo/expo-github-action/pull/56)) ([050b701](https://github.com/expo/expo-github-action/commit/050b701))
### Other chores
* upgrade all dependencies to latest version ([#55](https://github.com/expo/expo-github-action/pull/55)) ([404bd09](https://github.com/expo/expo-github-action/commit/404bd09))
## [5.1.1](https://github.com/expo/expo-github-action/compare/5.1.0...5.1.1) (2020-06-10)
### Bug fixes
* use inputs metadata key ([#49](https://github.com/expo/expo-github-action/pull/49)) ([71dfeab](https://github.com/expo/expo-github-action/commit/71dfeab))
## [5.1.0](https://github.com/expo/expo-github-action/compare/5.0.0...5.1.0) (2020-05-08)
### New features
+57
View File
@@ -0,0 +1,57 @@
# Contributing to Expo Github Action
## 📦 Download and Setup
1. [Fork](https://help.github.com/articles/fork-a-repo/) this repository to your own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) it to your local device. (`git remote add upstream [email protected]:expo/expo-github-action.git` 😉)
2. Make sure you have the following packages globally installed on your system:
- [node](https://nodejs.org/) (active Node LTS or higher is recommended)
- [yarn](https://yarnpkg.com/)
3. Install the Node packages (`yarn install`)
## 🏎️ Running a custom version
To try out your changed with Github Action, you have [to reference your fork and/or branch or commit reference](https://docs.github.com/en/actions/learn-github-actions/finding-and-customizing-actions#using-release-management-for-your-custom-actions) in the workflow you want to try. After that, you have two options:
1. Run the workflow in Github Actions itself by triggering your workflow.
2. Run the workflow locally with [nektos/act](https://github.com/nektos/act).
## ✅ Testing
Testing is done using [Jest](https://jestjs.io/https://jestjs.io/). Run `yarn test` to run Jest.
In CI we are running tests on multiple Node versions using Windows, Linux, and MacOS. Make sure they are passing for your PR.
## 📝 Writing a Commit Message
> If this is your first time committing to a large public repo, you could look through this neat tutorial: ["How to Write a Git Commit Message"](https://chris.beams.io/posts/git-commit/)
Commit messages are formatted using the [Conventional Commits](https://www.conventionalcommits.org/) format. You can take a look at [`.releaserc.js`](./.releaserc.js) for the allowed commit types.
```
docs: fix typo in xxx
feature: add support for SDK 40
chore: add test-case for custom completions
fix: improve logging for errors
refactor: update loading icon
```
## 🔎 Before Submitting a PR
To get your PR merged as fast as possible, please make sure you have done the following:
- Run `yarn lint --fix` to fix the formatting of the code. Ensure that `yarn lint` succeeds without errors or warnings.
- Run `yarn test` to make sure all normal use cases are passing.
- Run `yarn build` to ensure the build is up-to-date and runs correctly and without errors or warnings.
## 🚀 Releasing a new version
To release a new version for Github Actions, we have to create a new release in Github. You can run the `Release` workflow to generate a new version, changelog, and Github release.
After the exact version tag is created, update the `v{major}` tag to the latest major version. Make sure you are on the default branch at the commit of versioning.
```bash
$ git checkout master
$ git fetch --tags && git pull
$ git tag --force v{major}
$ git push --force --tags
```
+1
View File
@@ -1,6 +1,7 @@
# The MIT License (MIT)
Copyright (c) 2019-present Cedric van Putten <me@bycedric.com>
Copyright (c) 2019-present 650 Industries, Inc. (aka Expo)
> Permission is hereby granted, free of charge, to any person obtaining a copy
+176 -101
View File
@@ -1,75 +1,98 @@
# Expo GitHub Action
Publish, build, or manage your [Expo][link-expo] project with GitHub Actions!
This action installs the [Expo CLI][link-expo-cli] on your preferred os and authenticates your project.
You can also use [the Docker image][link-docker-expo] in other Docker-based environments.
1. [What's inside?](#whats-inside)
2. [Used variables](#used-variables)
3. [Example workflows](#example-workflows)
4. [Things to know](#things-to-know)
<div align="center">
<h1>expo github action</h1>
<p></p>
<p>Publish, build or manage your <a href="https://github.com/expo/expo">Expo</a> app with Github Actions!</p>
<sup>
<a href="https://github.com/expo/expo-github-action/releases">
<img src="https://img.shields.io/github/release/expo/expo-github-action/all.svg?style=flat-square" alt="releases" />
</a>
<a href="https://github.com/expo/expo-github-action/actions">
<img src="https://img.shields.io/github/workflow/status/expo/expo-github-action/CI/main.svg?style=flat-square" alt="builds" />
</a>
<a href="https://github.com/expo/expo-github-action/blob/main/LICENSE.md">
<img src="https://img.shields.io/github/license/expo/expo-github-action?style=flat-square" alt="license" />
</a>
</sup>
<br />
<p align="center">
<a href="https://github.com/expo/expo-github-action#configuration-options"><b>Usage</b></a>
&nbsp;&nbsp;&mdash;&nbsp;&nbsp;
<a href="https://github.com/expo/expo-github-action#example-workflows"><b>Examples</b></a>
&nbsp;&nbsp;&mdash;&nbsp;&nbsp;
<a href="https://github.com/expo/expo-github-action#things-to-know"><b>Caveats</b></a>
&nbsp;&nbsp;&mdash;&nbsp;&nbsp;
<a href="https://github.com/expo/expo-github-action/blob/main/CHANGELOG.md"><b>Changelog</b></a>
</p>
<br />
</div>
## What's inside?
Within this Expo action, you have full access to the [Expo CLI][link-expo-cli] itself.
That means you can perform any command like login, publish, and build.
Also, this action takes care of authentication when both `expo-username` and `expo-password` variables are defined.
With this Expo action, you have full access to [Expo CLI][link-expo-cli] and [EAS CLI][link-eas-cli] itself.
It allows you to fully automate the `expo publish` or `expo build` process, leaving you with more time available for your project.
There are some additional features included to make the usage of this action as simple as possible, like caching and authentication.
## Used variables
## Configuration options
This action is customizable through variables; they are defined in the [`action.yml`][link-expo-cli-action].
This action is customizable through variables; they are defined in the [`action.yml`](action.yml).
Here is a summary of all the variables that you can use and their purpose.
variable | description
--- | ---
`expo-username` | The username of your Expo account. _(you can hardcode this or use secrets)_
`expo-password` | The password of your Expo account. _**([use this with secrets][link-actions-secrets])**_
`expo-version` | The Expo CLI you want to use. _(can be any semver range, defaults to `latest`)_
`expo-packager` | The package manager you want to use to install the CLI. _(can be `npm` or `yarn`, defaults to `yarn`)_
`expo-cache` | If it should the actions cache, [read more about it here](#using-the-built-in-cache) _(can be `true` or `false`, defaults to `false`)_
`expo-cache-key` | An optional custom remote cache key _(**warning**, only use this when you know what you are doing)_
`expo-patch-watchers` | If it should patch the `fs.inotify.` limits causing `ENOSPC` errors on Linux. _(can be `true` or `false`, defaults to `true`)_
| variable | default | description |
| ---------------- | ------- | ------------------------------------------------------------------------------------------------------------ |
| `expo-version` | - | [Expo CLI](https://github.com/expo/expo-cli) version to install, skips when omitted. |
| `expo-cache` | `false` | If it should use the [GitHub actions (remote) cache](#using-the-built-in-cache). |
| `expo-cache-key` | - | An optional custom (remote) cache key. _(**use with caution**)_ |
| `eas-version` | - | [EAS CLI](https://github.com/expo/eas-cli) version to install, skips when omitted. (`latest` is recommended) |
| `eas-cache` | `false` | If it should use the [GitHub actions (remote) cache](#using-the-built-in-cache). |
| `eas-cache-key` | - | An optional custom (remote) cache key. _(**use with caution**)_ |
| `packager` | `yarn` | The package manager to use. _(e.g. `npm`)_ |
| `token` | - | The token of your Expo account _(e.g. [`${{ secrets.EXPO_TOKEN }}`][link-actions-secrets])_ |
| `username` | - | The username of your Expo account _(e.g. `bycedric`)_ |
| `password` | - | The password of your Expo account _(e.g. [`${{ secrets.EXPO_CLI_PASSWORD }}`][link-actions-secrets])_ |
| `patch-watchers` | `true` | If it should [patch the `fs.inotify.` limits](#enospc-errors-on-linux). |
> It's recommended to set the `expo-version` to avoid breaking changes when a new major version is released.
> For more info on how to use this, please read the [workflow syntax documentation][link-actions-syntax-with].
> Never hardcode `expo-token` or `expo-password` in your workflow, use [secrets][link-actions-secrets] to store them.
> Using `latest` for `eas-version` is recommened, you should always have the latest version of this CLI installed.
## Example workflows
Before you dive into the workflow examples, you should know the basics of GitHub Actions.
You can read more about this in the [GitHub Actions documentation][link-actions].
1. [Publish on any push to master](#publish-on-any-push-to-master)
1. [Publish on any push to main](#publish-on-any-push-to-main)
2. [Cache Expo CLI for other jobs](#cache-expo-cli-for-other-jobs)
3. [Test PRs and publish a review version](#test-prs-and-publish-a-review-version)
4. [Test PRs on multiple nodes and systems](#test-prs-on-multiple-nodes-and-systems)
5. [Test and build web every day at 08:00](#test-and-build-web-every-day-at-0800)
3. [Creating a new EAS build](#creating-a-new-eas-build)
4. [Test PRs and publish a review version](#test-prs-and-publish-a-review-version)
5. [Test PRs on multiple nodes and systems](#test-prs-on-multiple-nodes-and-systems)
6. [Test and build web every day at 08:00](#test-and-build-web-every-day-at-0800)
7. [Authenticate using credentials](#authenticate-using-credentials)
### Publish on any push to master
### Publish on any push to main
Below you can see the example configuration to publish whenever the master branch is updated.
Below you can see the example configuration to publish whenever the main branch is updated.
The workflow listens to the `push` event and sets up Node 12 using the [Setup Node Action][link-actions-node].
It also authenticates the Expo project by defining both `expo-username` and `expo-password`.
It also auto-authenticates when the `token` is provided.
```yml
name: Expo Publish
on:
push:
branches:
- master
- main
jobs:
publish:
name: Install and publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12.x
- uses: expo/expo-github-action@v5
node-version: 14.x
- uses: expo/expo-github-action@v6
with:
expo-version: 3.x
expo-username: ${{ secrets.EXPO_CLI_USERNAME }}
expo-password: ${{ secrets.EXPO_CLI_PASSWORD }}
expo-version: 4.x
token: ${{ secrets.EXPO_TOKEN }}
- run: yarn install
- run: expo publish
```
@@ -77,8 +100,8 @@ jobs:
### Cache Expo CLI for other jobs
Below you can see a slightly modified version of the example above.
In this one, we enabled the built-in cache that will reuse a previous installed Expo CLI.
This skips the installation part and extracts the files directly, boosting the performance of your workflow.
In this one, we enabled the built-in cache that will reuse a previously installed Expo CLI.
It skips the installation part and extracts the files directly, boosting the performance of your workflow.
> You can [read more about the cache here](#using-the-built-in-cache)
@@ -87,31 +110,61 @@ name: Expo Publish
on:
push:
branches:
- master
- main
jobs:
publish:
name: Install and publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12.x
- uses: expo/expo-github-action@v5
node-version: 14.x
- uses: expo/expo-github-action@v6
with:
expo-version: 3.x
expo-username: ${{ secrets.EXPO_CLI_USERNAME }}
expo-password: ${{ secrets.EXPO_CLI_PASSWORD }}
expo-version: 4.x
expo-cache: true
token: ${{ secrets.EXPO_TOKEN }}
- run: yarn install
- run: expo publish
```
### Creating a new EAS build
You can also install [EAS](https://docs.expo.io/eas/) CLI with this Github Action.
Below we've swapped `expo-version` with `eas-version`, but you can also use them together.
Both the `token` and `username`/`password` is shared between both Expo and EAS CLI.
> We recommend using `latest` for `eas-version` to always have the most up-to-date version.
```yml
name: EAS build
on:
push:
branches:
- main
jobs:
build:
name: Create new build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 14.x
- uses: expo/expo-github-action@v6
with:
eas-version: latest
token: ${{ secrets.EXPO_TOKEN }}
- run: yarn install
- run: eas build
```
### Test PRs and publish a review version
Reviewing pull requests can take some time if you have to read every line of code.
To make this easier, you can publish the edited version of the PR using a dedicated release channel.
Below you can see an example of a workflow that publishes and comments when the app is ready for review.
To make this easier, you can publish the edited version of the PR using a [release channel][link-expo-release-channels].
Below you can see an example of a workflow that publishes and comments on te PR when the app is published.
```yml
name: Expo Review
@@ -121,18 +174,17 @@ jobs:
name: Install and publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12.x
- uses: expo/expo-github-action@v5
node-version: 14.x
- uses: expo/expo-github-action@v6
with:
expo-version: 3.x
expo-username: ${{ secrets.EXPO_CLI_USERNAME }}
expo-password: ${{ secrets.EXPO_CLI_PASSWORD }}
expo-version: 4.x
token: ${{ secrets.EXPO_TOKEN }}
- run: yarn install
- run: expo publish --release-channel=pr-${{ github.event.number }}
- uses: unsplash/comment-on-pr@master
- uses: unsplash/comment-on-pr@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
@@ -143,9 +195,8 @@ jobs:
With GitHub Actions, it's reasonably easy to set up a matrix build and test the app on multiple environments.
These matrixes can help to make sure your app runs smoothly on a broad set of different development machines.
The action below is only running on pull requests to avoid unnecessary builds.
> If you don't need automatic authentication, you can omit the `expo-username` and `expo-password` variables.
> If you don't need automatic authentication, you can omit the `token` variables.
```yml
name: Expo CI
@@ -159,13 +210,13 @@ jobs:
os: [ubuntu-latest, macOS-latest, windows-latest]
node: [10, 12, 13]
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- uses: expo/expo-github-action@v5
- uses: expo/expo-github-action@v6
with:
expo-version: 3.x
expo-version: 4.x
- run: yarn install
- run: yarn test
- run: expo doctor
@@ -174,8 +225,7 @@ jobs:
### Test and build web every day at 08:00
You can also schedule jobs by using the cron syntax.
It helps you update or check your app now and then.
For example, the [Expo CLI Docker images uses this][link-docker-expo-cron] to make sure the images are up to date.
It can help to minimize the number of updates your users have to install.
```yml
name: Expo Daily CI
@@ -187,64 +237,89 @@ jobs:
name: Daily Continuous Integration
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12.x
- uses: expo/expo-github-action@v5
node-version: 14.x
- uses: expo/expo-github-action@v6
with:
expo-version: 3.x
expo-version: 4.x
- run: yarn install
- run: yarn test
- run: expo build:web
```
### Authenticate using credentials
Instead of using an access token, you can also authenticate using credentials.
This is only possible when Expo CLI is installed.
```yml
name: Expo Publish
on:
push:
branches:
- main
jobs:
publish:
name: Install and publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 14.x
- uses: expo/expo-github-action@v6
with:
expo-version: 4.x
username: ${{ secrets.EXPO_CLI_USERNAME }}
password: ${{ secrets.EXPO_CLI_PASSWORD }}
- run: yarn install
- run: expo publish
```
## Things to know
### Automatic Expo login
You need to authenticate for some Expo commands as `expo publish` and `expo build:*`.
This project has an additional feature to make this easy and secure.
The action uses the [`EXPO_CLI_PASSWORD`][link-expo-cli-password] variable internally to make this happen.
You need to authenticate for some Expo commands like `expo publish` and `expo build`.
This action gives you configuration options to keep your workflow simple.
You can choose if you want to authenticate using an `EXPO_TOKEN` or account credentials.
Under the hood, it uses the [`EXPO_CLI_PASSWORD`][link-expo-cli-password] environment variable to make credentials authentication as secure as possible.
> Note, this action only uses your token or credentials to authenticate with Expo. It doesn't store these anywhere.
### Using the built-in cache
As of writing, GitHub Actions lacks a feature to "cache" files and directories in 3rd party actions.
That's why we implemented the [Cypress fork of the `actions/cache`][link-actions-cache-cypress] to enable some sort of caching.
You can opt-in to this by setting the `expo-cache` variable to `true`.
If you know what you are doing and need more control, you can also define a custom cache key with `expo-cache-key`.
You can opt-in to caching the installation, making it a lot faster.
Under the hood, it uses the [`@action/cache`][link-actions-cache-package] package to restore the Expo CLI installation.
This action generates a unique cache key for the OS, used packager, and exact version of the Expo CLI.
If you need more control over this cache, you can define a custom cache key with `expo-cache-key`.
> Note, this cache will count towards your [repo cache limit][link-actions-cache-limit].
> Note, this cache will count towards your [repo cache limit][link-actions-cache-limit]. The Expo and EAS CLI are stored in different caches.
### ENOSPC errors on Linux
React Native bundles are created by the Metro bundler, even when using Expo.
Unfortunately, this Metro bundler requires quite some resources.
As of writing, GitHub Actions has some small default values for the `fs.inotify` settings.
Inside we included a patch that increases these limits for the "active workflow" run.
When you run `expo publish` or `expo build`, a new bundle is created.
Creating these bundles require quite some resources.
As of writing, GitHub actions has some small default values for the `fs.inotify` settings.
Inside this action, we included a patch that increases these limits for the current workflow.
It increases the `max_user_instances`, `max_user_watches` and `max_queued_events` to `524288`.
You can disable this patch by setting the `expo-patch-watchers` to `false`.
You can disable this patch by setting the `patch-watchers` to `false`.
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
--- ---
<p align="center">
with :heart: <a href="https://bycedric.com" target="_blank">byCedric</a>
</p>
<div align="center">
<br />
with :heart:&nbsp;<strong>byCedric</strong>
<br />
</div>
[link-actions]: https://help.github.com/en/categories/automating-your-workflow-with-github-actions
[link-actions-cache]: https://github.com/actions/cache
[link-actions-cache-cypress]: https://github.com/cypress-io/github-actions-cache
[link-actions-cache-limit]: https://github.com/actions/cache#cache-limits
[link-actions-cache-package]: https://www.npmjs.com/package/@actions/cache
[link-actions-node]: https://github.com/actions/setup-node
[link-actions-secrets]: https://help.github.com/en/articles/virtual-environments-for-github-actions#creating-and-using-secrets-encrypted-variables
[link-actions-syntax-with]: https://help.github.com/en/articles/workflow-syntax-for-github-actions#jobsjob_idstepswith
[link-docker-expo]: https://github.com/bycedric/expo-cli-images
[link-docker-expo-cron]: https://github.com/byCedric/expo-cli-images/blob/d93389e52135d6a599853aed7893adc6a8b57c84/.github/workflows/daily-builds.yml#L5
[link-expo]: https://expo.io
[link-expo-cli]: https://docs.expo.io/versions/latest/workflow/expo-cli
[link-expo-cli-action]: action.yml
[link-expo-cli-password]: https://github.com/expo/expo-cli/blob/8ea616d8848a123270b97e226e33dcb3dde49653/packages/expo-cli/src/accounts.js#L94
[link-actions-secrets]: https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets
[link-expo-cli]: https://docs.expo.io/workflow/expo-cli/
[link-expo-cli-password]: https://github.com/expo/expo-cli/blob/master/packages/expo-cli/src/accounts.ts#L88-L90
[link-expo-release-channels]: https://docs.expo.io/distribution/release-channels/
[link-eas-cli]: https://github.com/expo/eas-cli#readme
[link-semver-playground]: https://semver.npmjs.com/
+23 -15
View File
@@ -8,22 +8,30 @@ branding:
runs:
using: node12
main: build/index.js
input:
inputs:
expo-version:
description: The Expo CLI version to install. (use any semver/dist-tag available)
default: latest
expo-username:
description: Your Expo username, for authentication.
expo-password:
description: Your Expo password, for authentication. (use with secrets)
expo-packager:
description: The package manager used to install the Expo CLI. (can be yarn or npm)
default: yarn
expo-patch-watchers:
description: If Expo should fix the default watchers limit, helps with ENOSPC errors. (can be true or false)
default: true
description: The Expo CLI version to install (use any semver/dist-tag available).
expo-cache:
description: If Expo should be stored in the GitHub Actions cache (can be true or false)
description: If Expo CLI should be stored in the GitHub Actions cache.
default: false
expo-cache-key:
description: A custom remote cache key to use (best to let GitHub Actions handle it)
description: A custom remote cache key to use for Expo CLI.
eas-version:
description: The EAS CLI version to install (use any semver/dist-tag available).
eas-cache:
description: If EAS CLI should be stored in the GitHub Actions cache.
default: false
eas-cache-key:
description: A custom remote cache key to use for EAS CLI.
username:
description: Your Expo username, for authentication.
token:
description: Your Expo token, for authentication. (use with secrets)
password:
description: Your Expo password, for authentication. (use with secrets)
packager:
description: The package manager used to install the Expo CLI. (can be yarn or npm)
default: yarn
patch-watchers:
description: If Expo should fix the default watchers limit, helps with ENOSPC errors. (can be true or false)
default: true
+144232 -54869
View File
File diff suppressed because it is too large. Load diff
+47
View File
@@ -0,0 +1,47 @@
'use strict'
const ls = require('../ls.js')
const get = require('../get.js')
const put = require('../put.js')
const rm = require('../rm.js')
const verify = require('../verify.js')
const setLocale = require('../lib/util/y.js').setLocale
const clearMemoized = require('../lib/memoization.js').clearMemoized
const tmp = require('../lib/util/tmp.js')
setLocale('en')
const x = module.exports
x.ls = cache => ls(cache)
x.ls.stream = cache => ls.stream(cache)
x.get = (cache, key, opts) => get(cache, key, opts)
x.get.byDigest = (cache, hash, opts) => get.byDigest(cache, hash, opts)
x.get.sync = (cache, key, opts) => get.sync(cache, key, opts)
x.get.sync.byDigest = (cache, key, opts) => get.sync.byDigest(cache, key, opts)
x.get.stream = (cache, key, opts) => get.stream(cache, key, opts)
x.get.stream.byDigest = (cache, hash, opts) => get.stream.byDigest(cache, hash, opts)
x.get.copy = (cache, key, dest, opts) => get.copy(cache, key, dest, opts)
x.get.copy.byDigest = (cache, hash, dest, opts) => get.copy.byDigest(cache, hash, dest, opts)
x.get.info = (cache, key) => get.info(cache, key)
x.get.hasContent = (cache, hash) => get.hasContent(cache, hash)
x.get.hasContent.sync = (cache, hash) => get.hasContent.sync(cache, hash)
x.put = (cache, key, data, opts) => put(cache, key, data, opts)
x.put.stream = (cache, key, opts) => put.stream(cache, key, opts)
x.rm = (cache, key) => rm.entry(cache, key)
x.rm.all = cache => rm.all(cache)
x.rm.entry = x.rm
x.rm.content = (cache, hash) => rm.content(cache, hash)
x.setLocale = lang => setLocale(lang)
x.clearMemoized = () => clearMemoized()
x.tmp = {}
x.tmp.mkdir = (cache, opts) => tmp.mkdir(cache, opts)
x.tmp.withTmp = (cache, opts, cb) => tmp.withTmp(cache, opts, cb)
x.verify = (cache, opts) => verify(cache, opts)
x.verify.lastRun = cache => verify.lastRun(cache)
+7
View File
@@ -0,0 +1,7 @@
{
"No cache entry for `%s` found in `%s`": "No cache entry for %s found in %s",
"Integrity verification failed for %s (%s)": "Integrity verification failed for %s (%s)",
"Bad data size: expected inserted data to be %s bytes, but got %s instead": "Bad data size: expected inserted data to be %s bytes, but got %s instead",
"Cache input stream was empty": "Cache input stream was empty",
"Integrity check failed:\n Wanted: %s\n Found: %s": "Integrity check failed:\n Wanted: %s\n Found: %s"
}
+49
View File
@@ -0,0 +1,49 @@
'use strict'
const ls = require('../ls.js')
const get = require('../get.js')
const put = require('../put.js')
const rm = require('../rm.js')
const verify = require('../verify.js')
const setLocale = require('../lib/util/y.js').setLocale
const clearMemoized = require('../lib/memoization.js').clearMemoized
const tmp = require('../lib/util/tmp.js')
setLocale('es')
const x = module.exports
x.ls = cache => ls(cache)
x.ls.flujo = cache => ls.stream(cache)
x.saca = (cache, clave, ops) => get(cache, clave, ops)
x.saca.porHacheo = (cache, hacheo, ops) => get.byDigest(cache, hacheo, ops)
x.saca.sinc = (cache, clave, ops) => get.sync(cache, clave, ops)
x.saca.sinc.porHacheo = (cache, hacheo, ops) => get.sync.byDigest(cache, hacheo, ops)
x.saca.flujo = (cache, clave, ops) => get.stream(cache, clave, ops)
x.saca.flujo.porHacheo = (cache, hacheo, ops) => get.stream.byDigest(cache, hacheo, ops)
x.sava.copia = (cache, clave, destino, opts) => get.copy(cache, clave, destino, opts)
x.sava.copia.porHacheo = (cache, hacheo, destino, opts) => get.copy.byDigest(cache, hacheo, destino, opts)
x.saca.info = (cache, clave) => get.info(cache, clave)
x.saca.tieneDatos = (cache, hacheo) => get.hasContent(cache, hacheo)
x.saca.tieneDatos.sinc = (cache, hacheo) => get.hasContent.sync(cache, hacheo)
x.mete = (cache, clave, datos, ops) => put(cache, clave, datos, ops)
x.mete.flujo = (cache, clave, ops) => put.stream(cache, clave, ops)
x.rm = (cache, clave) => rm.entry(cache, clave)
x.rm.todo = cache => rm.all(cache)
x.rm.entrada = x.rm
x.rm.datos = (cache, hacheo) => rm.content(cache, hacheo)
x.ponLenguaje = lang => setLocale(lang)
x.limpiaMemoizado = () => clearMemoized()
x.tmp = {}
x.tmp.mkdir = (cache, ops) => tmp.mkdir(cache, ops)
x.tmp.hazdir = x.tmp.mkdir
x.tmp.conTmp = (cache, ops, cb) => tmp.withTmp(cache, ops, cb)
x.verifica = (cache, ops) => verify(cache, ops)
x.verifica.ultimaVez = cache => verify.lastRun(cache)
x.verifica.últimaVez = x.verifica.ultimaVez
+6
View File
@@ -0,0 +1,6 @@
{
"No cache entry for `%s` found in `%s`": "No existe ninguna entrada para «%s» en «%s»",
"Integrity verification failed for %s (%s)": "Verificación de integridad falló para «%s» (%s)",
"Bad data size: expected inserted data to be %s bytes, but got %s instead": "Tamaño incorrecto de datos: los datos insertados debieron haber sido %s octetos, pero fueron %s",
"Cache input stream was empty": "El stream de entrada al caché estaba vacío"
}
+30 -25
View File
@@ -1,7 +1,7 @@
{
"private": true,
"name": "expo-github-action",
"version": "5.1.0",
"version": "6.0.0",
"description": "Expo CLI in your GitHub Actions workflow",
"main": "build/index.js",
"repository": {
@@ -17,33 +17,38 @@
"scripts": {
"test": "jest",
"lint": "tsc --noEmit && eslint --ext ts ./src ./tests",
"build": "ncc build src/index.ts --out build"
"build": "ncc build src/index.ts --out build",
"clean": "rimraf build",
"prepare": "husky install"
},
"dependencies": {
"@actions/cache": "github:cypress-io/github-actions-cache#8bec6cc",
"@actions/core": "^1.2.4",
"@actions/exec": "^1.0.4",
"@actions/io": "^1.0.2",
"@actions/tool-cache": "^1.3.4",
"libnpm": "^3.0.1"
"@actions/cache": "^1.0.7",
"@actions/core": "^1.4.0",
"@actions/exec": "^1.1.0",
"@actions/io": "^1.1.1",
"@actions/tool-cache": "^1.7.1",
"libnpm": "^3.0.1",
"semver": "^7.3.5"
},
"devDependencies": {
"@types/jest": "^25.2.1",
"@types/node": "^13.13.5",
"@typescript-eslint/eslint-plugin": "^2.31.0",
"@typescript-eslint/parser": "^2.31.0",
"@zeit/ncc": "^0.22.1",
"eslint": "^6.8.0",
"eslint-plugin-jest": "^23.9.0",
"husky": "^3.1.0",
"jest": "^26.0.1",
"jest-circus": "^26.0.1",
"ts-jest": "^25.5.0",
"typescript": "^3.8.3"
},
"husky": {
"hooks": {
"pre-commit": "npm run build && git add build"
}
"@semantic-release/changelog": "^5.0.1",
"@semantic-release/git": "^9.0.0",
"@tsconfig/node14": "^1.0.1",
"@types/jest": "^26.0.23",
"@types/node": "^14.17.3",
"@types/semver": "^7.3.6",
"@typescript-eslint/eslint-plugin": "^4.27.0",
"@typescript-eslint/parser": "^4.27.0",
"@zeit/ncc": "^0.22.3",
"conventional-changelog-conventionalcommits": "^4.6.0",
"eslint": "^7.28.0",
"eslint-plugin-jest": "^24.3.6",
"husky": "^6.0.0",
"jest": "^27.0.4",
"jest-circus": "^27.0.4",
"rimraf": "^3.0.2",
"semantic-release": "^17.4.4",
"ts-jest": "^27.0.3",
"typescript": "^4.3.3"
}
}
+56 -16
View File
@@ -1,16 +1,21 @@
import { restoreCache, saveCache } from '@actions/cache/lib';
import { ReserveCacheError, restoreCache, saveCache } from '@actions/cache';
import * as core from '@actions/core';
import * as toolCache from '@actions/tool-cache';
import path from 'path';
import os from 'os';
import type { InstallConfig } from './install';
export type CacheConfig = Omit<InstallConfig, 'cache'>;
/**
* Get the path to the `expo-cli` from cache, if any.
* Note, this cache is **NOT** shared between jobs.
*
* @see https://github.com/actions/toolkit/issues/47
*/
export async function fromLocalCache(version: string) {
return toolCache.find('expo-cli', version);
export async function fromLocalCache(config: CacheConfig): Promise<string | undefined> {
return toolCache.find(config.package, config.version);
}
/**
@@ -19,22 +24,29 @@ export async function fromLocalCache(version: string) {
*
* @see https://github.com/actions/toolkit/issues/47
*/
export async function toLocalCache(root: string, version: string) {
return toolCache.cacheDir(root, 'expo-cli', version);
export async function toLocalCache(root: string, config: CacheConfig): Promise<string> {
return toolCache.cacheDir(root, config.package, config.version);
}
/**
* Download the remotely stored `expo-cli` from cache, if any.
* Note, this cache is shared between jobs.
*/
export async function fromRemoteCache(version: string, packager: string, customCacheKey?: string) {
export async function fromRemoteCache(config: CacheConfig): Promise<string | undefined> {
// see: https://github.com/actions/toolkit/blob/8a4134761f09d0d97fb15f297705fd8644fef920/packages/tool-cache/src/tool-cache.ts#L401
const target = path.join(process.env['RUNNER_TOOL_CACHE'] || '', 'expo-cli', version, os.arch());
const cacheKey = customCacheKey || getRemoteKey(version, packager);
const hit = await restoreCache(target, cacheKey, cacheKey);
const target = path.join(process.env['RUNNER_TOOL_CACHE'] || '', config.package, config.version, os.arch());
const cacheKey = config.cacheKey || getRemoteKey(config);
if (hit) {
return target;
try {
// When running with nektos/act, or other custom environments, the cache might not be set up.
const hit = await restoreCache([target], cacheKey);
if (hit) {
return target;
}
} catch (error) {
if (!handleRemoteCacheError(error)) {
throw error;
}
}
}
@@ -42,15 +54,43 @@ export async function fromRemoteCache(version: string, packager: string, customC
* Store the root of `expo-cli` in the remote cache, for future reuse.
* Note, this cache is shared between jobs.
*/
export async function toRemoteCache(source: string, version: string, packager: string, customCacheKey?: string) {
const cacheKey = customCacheKey || getRemoteKey(version, packager);
export async function toRemoteCache(source: string, config: CacheConfig): Promise<void> {
const cacheKey = config.cacheKey || getRemoteKey(config);
await saveCache(source, cacheKey);
try {
await saveCache([source], cacheKey);
} catch (error) {
if (!handleRemoteCacheError(error)) {
throw error;
}
}
}
/**
* Get the cache key to use when (re)storing the Expo CLI from remote cache.
*/
function getRemoteKey(version: string, packager: string) {
return `expo-cli-${process.platform}-${os.arch()}-${packager}-${version}`;
function getRemoteKey(config: Omit<CacheConfig, 'cacheKey'>): string {
return `${config.package}-${process.platform}-${os.arch()}-${config.packager}-${config.version}`;
}
/**
* Handle any incoming errors from cache methods.
* This can include actual errors like `ReserveCacheErrors` or unavailability errors.
* When the error is handled, it MUST provide feedback for the developer.
*
* @returns If the error was handled properly.
*/
function handleRemoteCacheError(error: Error): boolean {
const isReserveCacheError = error instanceof ReserveCacheError;
const isCacheUnavailable = error.message.toLowerCase().includes(
'cache service url not found',
);
if (isReserveCacheError || isCacheUnavailable) {
core.warning('Skipping remote cache storage, encountered error:');
core.warning(error.message);
return true;
}
return false;
}
-25
View File
@@ -1,25 +0,0 @@
import * as core from '@actions/core';
import * as cli from '@actions/exec';
/**
* Authenticate at Expo using `expo login`.
* This step is required for publishing and building new apps.
* It uses the `EXPO_CLI_PASSWORD` environment variable for improved security.
*/
export async function authenticate(username: string, password: string) {
if (!username || !password) {
return core.info('Skipping authentication, `expo-username` and/or `expo-password` not set...');
}
// github actions toolkit will handle commands with `.cmd` on windows, we need that
const bin = process.platform === 'win32'
? 'expo.cmd'
: 'expo';
await cli.exec(bin, ['login', `--username=${username}`], {
env: {
...process.env,
EXPO_CLI_PASSWORD: password,
},
});
}
+1 -2
View File
@@ -1,4 +1,3 @@
import * as core from '@actions/core';
import { run } from './run';
run().catch(core.setFailed);
run();
+19 -29
View File
@@ -2,53 +2,43 @@ import * as core from '@actions/core';
import * as cli from '@actions/exec';
import * as io from '@actions/io';
import * as path from 'path';
import {
fromLocalCache,
fromRemoteCache,
toLocalCache,
toRemoteCache,
} from './cache';
// eslint-disable-next-line @typescript-eslint/no-var-requires
const registry = require('libnpm');
import { fromLocalCache, fromRemoteCache, toLocalCache, toRemoteCache } from './cache';
import { PackageName } from './tools';
interface InstallConfig {
export type InstallConfig = {
/** The exact version to install */
version: string;
/** The name of the package to install */
package: PackageName;
/** The packager to install with, likely to be `yarn` or `npm` */
packager: string;
/** If remote caching is enabled or not */
cache?: boolean;
/** The custom remote cache key */
cacheKey?: string;
}
/**
* Resolve the provided semver to exact version of `expo-cli`.
* This uses the npm registry and accepts latest, dist-tags or version ranges.
* It's used to determine the cached version of `expo-cli`.
*/
export async function resolve(version: string) {
return (await registry.manifest(`expo-cli@${version}`)).version;
}
};
/**
* Install `expo-cli`, by version, using the packager.
* Here you can provide any semver range or dist tag used in the registry.
* It returns the path where Expo is installed.
*/
export async function install(config: InstallConfig) {
const exact = await resolve(config.version);
let root: string | undefined = await fromLocalCache(exact);
export async function install(config: InstallConfig): Promise<string> {
let root: string | undefined = await fromLocalCache(config);
if (!root && config.cache) {
root = await fromRemoteCache(exact, config.packager, config.cacheKey);
root = await fromRemoteCache(config);
} else {
core.info('Skipping remote cache, not enabled...');
}
if (!root) {
root = await fromPackager(exact, config.packager)
root = await toLocalCache(root, exact);
root = await fromPackager(config);
root = await toLocalCache(root, config);
if (config.cache) {
await toRemoteCache(root, exact, config.packager, config.cacheKey);
await toRemoteCache(root, config);
}
}
@@ -59,12 +49,12 @@ export async function install(config: InstallConfig) {
* Install `expo-cli`, by version, using npm or yarn.
* It creates a temporary directory to store all required files.
*/
export async function fromPackager(version: string, packager: string) {
export async function fromPackager(config: InstallConfig): Promise<string> {
const root = process.env['RUNNER_TEMP'] || '';
const tool = await io.which(packager);
const tool = await io.which(config.packager);
await io.mkdirP(root);
await cli.exec(tool, ['add', `expo-cli@${version}`], { cwd: root });
await cli.exec(tool, ['add', `${config.package}@${config.version}`], { cwd: root });
return root;
}
+51 -19
View File
@@ -1,26 +1,58 @@
import { addPath, getInput } from '@actions/core';
import { authenticate } from './expo';
import { addPath, getInput, group, info } from '@actions/core';
import { install } from './install';
import { patchWatchers } from './system';
import * as tools from './tools';
export async function run() {
const path = await install({
version: getInput('expo-version') || 'latest',
packager: getInput('expo-packager') || 'yarn',
cache: (getInput('expo-cache') || 'false') === 'true',
cacheKey: getInput('expo-cache-key') || undefined,
});
export async function run(): Promise<void> {
const expoVersion = await installCli('expo-cli');
const easVersion = await installCli('eas-cli');
addPath(path);
await authenticate(
getInput('expo-username'),
getInput('expo-password'),
await group(
'Checking current authenticated account',
() => tools.maybeAuthenticate({
cli: expoVersion ? 'expo-cli' : easVersion ? 'eas-cli' : undefined,
token: getInput('token') || undefined,
username: getInput('username') || undefined,
password: getInput('password') || undefined,
}),
);
const shouldPatchWatchers = getInput('expo-patch-watchers') || 'true';
if (shouldPatchWatchers !== 'false') {
await patchWatchers();
if (tools.getBoolean(getInput('patch-watchers'), true)) {
await group(
'Patching system watchers for the `ENOSPC` error',
() => tools.maybePatchWatchers(),
);
}
}
async function installCli(name: tools.PackageName): Promise<string | void> {
const shortName = tools.getBinaryName(name);
const inputVersion = getInput(`${shortName}-version`);
const packager = getInput('packager') || 'yarn';
if (!inputVersion) {
return info(`Skipping installation of ${name}, \`${shortName}-version\` not provided.`);
}
const version = await tools.resolveVersion(name, inputVersion);
const cache = tools.getBoolean(getInput(`${shortName}-cache`), false);
try {
const path = await group(
cache
? `Installing ${name} (${version}) from cache or with ${packager}`
: `Installing ${name} (${version}) with ${packager}`,
() => install({
packager, version, cache,
package: name,
cacheKey: getInput(`${shortName}-cache-key`) || undefined,
}),
);
addPath(path);
} catch (error) {
tools.handleError(name, error);
}
return version;
}
-28
View File
@@ -1,28 +0,0 @@
import * as core from '@actions/core';
import * as cli from '@actions/exec';
/**
* Try to patch the default watcher/inotify limit.
* This is a limitation from GitHub Actions and might be an issue in some Expo projects.
* It sets the system's `fs.inotify` limits to a more sensible setting.
*
* @see https://github.com/expo/expo-github-action/issues/20
*/
export async function patchWatchers() {
if (process.platform !== 'linux') {
return core.info('Skipping patch for watchers, not running on Linux...');
}
core.info('Patching system watchers for the `ENOSPC` error...');
try {
// see https://github.com/expo/expo-cli/issues/277#issuecomment-452685177
await cli.exec('sudo sysctl fs.inotify.max_user_instances=524288');
await cli.exec('sudo sysctl fs.inotify.max_user_watches=524288');
await cli.exec('sudo sysctl fs.inotify.max_queued_events=524288');
await cli.exec('sudo sysctl -p');
} catch {
core.warning('Looks like we can\'t patch watchers/inotify limits, you might encouter the `ENOSPC` error.');
core.warning('For more info, https://github.com/expo/expo-github-action/issues/20');
}
}
+132
View File
@@ -0,0 +1,132 @@
import * as core from '@actions/core';
import * as cli from '@actions/exec';
import semver from 'semver';
// eslint-disable-next-line @typescript-eslint/no-var-requires
const registry = require('libnpm');
export type PackageName = 'expo-cli' | 'eas-cli';
export type AuthenticateOptions = {
cli?: PackageName;
token?: string;
username?: string;
password?: string;
};
/**
* Get a boolean value from string, useful for Github Actions boolean inputs.
*/
export function getBoolean(value: string, defaultValue = false): boolean {
return (value.toLowerCase() || (defaultValue ? 'true' : 'false')) === 'true';
}
/**
* Convert `expo-cli` or `eas-cli` to just their binary name.
* For windows we have to use `<bin>.cmd`, toolkit will handle the Windows binary with that.
*/
export function getBinaryName(name: PackageName, forWindows = false): string {
const bin = name.toLowerCase().replace('-cli', '');
return forWindows ? `${bin}.cmd` : bin;
}
/**
* Resolve the provided semver to exact version of `expo-cli`.
* This uses the npm registry and accepts latest, dist-tags or version ranges.
* It's used to determine the cached version of `expo-cli`.
*/
export async function resolveVersion(name: PackageName, version: string): Promise<string> {
return (await registry.manifest(`${name}@${version}`)).version;
}
/**
* Authenticate with Expo using either the token or username/password method.
* If both of them are set, token has priority.
*/
export async function maybeAuthenticate(options: AuthenticateOptions = {}): Promise<void> {
if (options.token) {
if (options.cli) {
const bin = getBinaryName(options.cli, process.platform === 'win32');
await cli.exec(bin, ['whoami'], {
env: { ...process.env, EXPO_TOKEN: options.token },
});
} else {
core.info('Skipping token validation: no CLI installed, can\'t run `whoami`.');
}
return core.exportVariable('EXPO_TOKEN', options.token);
}
if (options.username || options.password) {
if (options.cli !== 'expo-cli') {
return core.warning('Skipping authentication: only Expo CLI supports programmatic credentials, use `token` instead.');
}
if (!options.username || !options.password) {
return core.info('Skipping authentication: `username` and/or `password` not set...');
}
const bin = getBinaryName(options.cli, process.platform === 'win32');
await cli.exec(bin, ['login', `--username=${options.username}`], {
env: { ...process.env, EXPO_CLI_PASSWORD: options.password },
});
}
core.info('Skipping authentication: `token`, `username`, and/or `password` not set...');
}
/**
* Try to patch the default watcher/inotify limit.
* This is a limitation from GitHub Actions and might be an issue in some Expo projects.
* It sets the system's `fs.inotify` limits to a more sensible setting.
*
* @see https://github.com/expo/expo-github-action/issues/20
*/
export async function maybePatchWatchers(): Promise<void> {
if (process.platform !== 'linux') {
return core.info('Skipping patch for watchers, not running on Linux...');
}
core.info('Patching system watchers for the `ENOSPC` error...');
try {
// see https://github.com/expo/expo-cli/issues/277#issuecomment-452685177
await cli.exec('sudo sysctl fs.inotify.max_user_instances=524288');
await cli.exec('sudo sysctl fs.inotify.max_user_watches=524288');
await cli.exec('sudo sysctl fs.inotify.max_queued_events=524288');
await cli.exec('sudo sysctl -p');
} catch {
core.warning("Looks like we can't patch watchers/inotify limits, you might encouter the `ENOSPC` error.");
core.warning('For more info, https://github.com/expo/expo-github-action/issues/20');
}
}
/**
* Check if there is a new major version available.
* If there is, create a warning for people to upgrade their workflow.
* Because this introduces additional requests, it should only be executed when necessary.
*/
export async function maybeWarnForUpdate(name: PackageName): Promise<void> {
const binaryName = getBinaryName(name);
const latest = await resolveVersion(name, 'latest');
const current = await resolveVersion(name, core.getInput(`${getBinaryName(name)}-version`) || 'latest');
if (semver.diff(latest, current) === 'major') {
core.warning(`There is a new major version available of the Expo CLI (${latest})`);
core.warning(`If you run into issues, try upgrading your workflow to "${binaryName}-version: ${semver.major(latest)}.x"`);
}
}
/**
* Handle errors when this action fails, providing useful next-steps for developers.
* This mostly checks if the installed version is the latest version.
*/
export async function handleError(name: PackageName, error: Error) {
try {
await maybeWarnForUpdate(name);
} catch {
// If this fails, ignore it
}
core.setFailed(error);
}
+88 -36
View File
@@ -1,97 +1,149 @@
import * as remoteCache from '@actions/cache/lib';
import * as toolCache from '@actions/tool-cache';
import os from 'os';
import { join } from 'path';
import * as remoteCache from '@actions/cache';
import * as core from '@actions/core';
import * as toolCache from '@actions/tool-cache';
import * as cache from '../src/cache';
import * as utils from './utils';
describe('fromLocalCache', () => {
describe(cache.fromLocalCache, () => {
it('fetches the version specific cache', async () => {
const path = '/path/to/local/cache';
const path = join('path', 'to', 'local', 'cache');
// todo: check why jest wants `never` instead of `string`
const find = jest.spyOn(toolCache, 'find').mockResolvedValue(path as never);
const result = await cache.fromLocalCache('3.20.1');
const result = await cache.fromLocalCache({ package: 'eas-cli', version: '4.2.0', packager: 'npm' });
expect(result).toBe(path);
expect(find).toBeCalledWith('expo-cli', '3.20.1');
expect(find).toBeCalledWith('eas-cli', '4.2.0');
});
});
describe('toLocalCache', () => {
describe(cache.toLocalCache, () => {
it('stores the version specific cache', async () => {
const path = '/path/to/local/cache';
const root = '/path/from/source';
const path = join('path', 'to', 'local', 'cache');
const root = join('path', 'from', 'source');
const cacheDir = jest.spyOn(toolCache, 'cacheDir').mockResolvedValue(path);
const result = await cache.toLocalCache(root, '3.20.1');
const result = await cache.toLocalCache(root, { package: 'expo-cli', version: '4.2.0', packager: 'yarn' });
expect(result).toBe(path);
expect(cacheDir).toBeCalledWith(root, 'expo-cli', '3.20.1');
expect(cacheDir).toBeCalledWith(root, 'expo-cli', '4.2.0');
});
});
describe('fromRemoteCache', () => {
const spy = {
restore: jest.spyOn(remoteCache, 'restoreCache').mockImplementation(),
};
describe(cache.fromRemoteCache, () => {
let spy: { [key: string]: jest.SpyInstance } = {};
beforeEach(() => {
spy = {
restore: jest.spyOn(remoteCache, 'restoreCache').mockImplementation(),
warning: jest.spyOn(core, 'warning').mockImplementation(),
};
});
beforeAll(() => {
utils.setEnv('RUNNER_TOOL_CACHE', '/cache/path');
utils.setEnv('RUNNER_TOOL_CACHE', join('cache', 'path'));
});
afterAll(() => {
utils.restoreEnv();
spy.restore.mockRestore();
spy.warning.mockRestore();
});
it('restores remote cache with default key', async () => {
expect(await cache.fromRemoteCache('3.20.1', 'yarn')).toBeUndefined();
expect(await cache.fromRemoteCache({ package: 'expo-cli', version: '3.20.1', packager: 'yarn' })).toBeUndefined();
expect(remoteCache.restoreCache).toBeCalledWith(
`/cache/path/expo-cli/3.20.1/${os.arch()}`,
`expo-cli-${process.platform}-${os.arch()}-yarn-3.20.1`,
[join('cache', 'path', 'expo-cli', '3.20.1', os.arch())],
`expo-cli-${process.platform}-${os.arch()}-yarn-3.20.1`,
);
});
it('restores remote cache with custom key', async () => {
expect(await cache.fromRemoteCache('3.20.0', 'yarn', 'custom-cache-key')).toBeUndefined();
expect(
await cache.fromRemoteCache({
package: 'eas-cli',
version: '4.2.0',
packager: 'yarn',
cacheKey: 'custom-cache-key',
})
).toBeUndefined();
expect(remoteCache.restoreCache).toBeCalledWith(
`/cache/path/expo-cli/3.20.0/${os.arch()}`,
'custom-cache-key',
[join('cache', 'path', 'eas-cli', '4.2.0', os.arch())],
'custom-cache-key',
);
});
it('returns path when remote cache exists', async () => {
spy.restore.mockResolvedValueOnce(true);
await expect(cache.fromRemoteCache('3.20.1', 'npm')).resolves.toBe(
`/cache/path/expo-cli/3.20.1/${os.arch()}`,
);
expect(
await cache.fromRemoteCache({ package: 'expo-cli', version: '3.20.1', packager: 'npm' })
).toBe(join('cache', 'path', 'expo-cli', '3.20.1', os.arch()));
});
it('fails when remote cache throws', async () => {
const error = new Error('Remote cache restore failed');
spy.restore.mockRejectedValueOnce(error);
await expect(cache.fromRemoteCache('3.20.1', 'yarn')).rejects.toBe(error);
await expect(cache.fromRemoteCache({ package: 'eas-cli', version: '3.20.1', packager: 'yarn' })).rejects.toBe(error);
});
it('skips remote cache when unavailable', async () => {
// see: https://github.com/actions/toolkit/blob/9167ce1f3a32ad495fc1dbcb574c03c0e013ae53/packages/cache/src/internal/cacheHttpClient.ts#L41
const error = new Error('Cache Service Url not found, unable to restore cache.');
spy.restore.mockRejectedValueOnce(error);
expect(
await cache.fromRemoteCache({ package: 'expo-cli', version: '3.20.1', packager: 'yarn' })
).toBeUndefined();
expect(spy.warning).toHaveBeenCalledWith(expect.stringContaining('Skipping remote cache'));
});
});
describe('toRemoteCache', () => {
const spy = {
save: jest.spyOn(remoteCache, 'saveCache').mockImplementation(),
};
describe(cache.toRemoteCache, () => {
let spy: { [key: string]: jest.SpyInstance } = {};
beforeEach(() => {
spy = {
save: jest.spyOn(remoteCache, 'saveCache').mockImplementation(),
warning: jest.spyOn(core, 'warning').mockImplementation(),
};
});
afterAll(() => {
spy.save.mockRestore();
spy.warning.mockRestore();
});
it('saves remote cache with default key', async () => {
expect(await cache.toRemoteCache('/local/path', '3.20.1', 'npm')).toBeUndefined();
expect(await cache.toRemoteCache(join('local', 'path'), { package: 'eas-cli', version: '3.20.1', packager: 'npm' })).toBeUndefined();
expect(remoteCache.saveCache).toBeCalledWith(
'/local/path',
`expo-cli-${process.platform}-${os.arch()}-npm-3.20.1`,
[join('local', 'path')],
`eas-cli-${process.platform}-${os.arch()}-npm-3.20.1`
);
});
it('saves remote cache with custom key', async () => {
expect(await cache.toRemoteCache('/local/path', '3.20.1', 'yarn', 'custom-cache-key')).toBeUndefined();
expect(remoteCache.saveCache).toBeCalledWith('/local/path', 'custom-cache-key');
expect(await cache.toRemoteCache(
join('local', 'path'),
{ package: 'eas-cli', version: '3.20.1', packager: 'yarn', cacheKey: 'custom-cache-key' }
)).toBeUndefined();
expect(remoteCache.saveCache).toBeCalledWith([join('local', 'path')], 'custom-cache-key');
});
it('fails when remote cache throws', async () => {
const error = new Error('Remote cache save failed');
spy.save.mockRejectedValueOnce(error);
await expect(cache.toRemoteCache('/local/path', '3.20.1', 'yarn')).rejects.toBe(error);
await expect(cache.toRemoteCache(
join('local', 'path'),
{ package: 'expo-cli', version: '3.20.1', packager: 'yarn' },
)).rejects.toBe(error);
});
it('skips remote cache when unavailable', async () => {
// see: https://github.com/actions/toolkit/blob/9167ce1f3a32ad495fc1dbcb574c03c0e013ae53/packages/cache/src/internal/cacheHttpClient.ts#L41
const error = new Error('Cache Service Url not found, unable to restore cache.');
spy.save.mockRejectedValueOnce(error);
await expect(cache.toRemoteCache(
join('local', 'path'),
{ package: 'expo-cli', version: '3.20.1', packager: 'yarn' },
)).resolves.toBeUndefined();
expect(spy.warning).toHaveBeenCalledWith(expect.stringContaining('Skipping remote cache'));
});
});
-52
View File
@@ -1,52 +0,0 @@
import * as core from '@actions/core';
import * as cli from '@actions/exec';
import * as expo from '../src/expo';
import * as utils from './utils';
describe('authenticate', () => {
const spy = {
exec: jest.spyOn(cli, 'exec').mockImplementation(),
info: jest.spyOn(core, 'info').mockImplementation(),
};
it('skips authentication without credentials', async () => {
await expo.authenticate('', '');
expect(spy.exec).not.toBeCalled();
expect(spy.info).toBeCalled();
});
it('skips authentication without password', async () => {
await expo.authenticate('bycedric', '');
expect(spy.exec).not.toBeCalled();
expect(spy.info).toBeCalled();
});
it('executes login command with password through environment', async () => {
utils.setEnv('TEST_INCLUDED', 'hellyeah');
await expo.authenticate('bycedric', 'mypassword');
expect(spy.exec).toBeCalled();
expect(spy.exec.mock.calls[0][0]).toBe('expo');
expect(spy.exec.mock.calls[0][1]).toStrictEqual(['login', '--username=bycedric'])
expect(spy.exec.mock.calls[0][2]).toMatchObject({
env: {
TEST_INCLUDED: 'hellyeah',
EXPO_CLI_PASSWORD: 'mypassword',
},
});
utils.restoreEnv();
});
it('executes login command with `.cmd` suffix on windows', async () => {
utils.setPlatform('win32');
await expo.authenticate('bycedric', 'mypassword');
expect(spy.exec).toBeCalled();
expect(spy.exec.mock.calls[0][0]).toBe('expo.cmd');
utils.restorePlatform();
});
it('fails when credentials are incorrect', async () => {
const error = new Error('Invalid username/password. Please try again.');
spy.exec.mockRejectedValue(error);
await expect(expo.authenticate('bycedric', 'incorrect')).rejects.toBe(error);
});
});
+28 -38
View File
@@ -1,6 +1,5 @@
const cli = { exec: jest.fn() };
const io = { mkdirP: jest.fn(), which: jest.fn() };
const registry = { manifest: jest.fn() };
const cache = {
fromLocalCache: jest.fn(),
fromRemoteCache: jest.fn(),
@@ -10,81 +9,72 @@ const cache = {
jest.mock('@actions/exec', () => cli);
jest.mock('@actions/io', () => io);
jest.mock('libnpm', () => registry);
jest.mock('../src/cache', () => cache);
import { join } from 'path';
import * as install from '../src/install';
import * as utils from './utils';
describe('resolve', () => {
it('fetches exact version of expo-cli', async () => {
registry.manifest.mockResolvedValue({ version: '3.0.10' });
expect(await install.resolve('latest')).toBe('3.0.10');
expect(registry.manifest).toBeCalledWith('expo-cli@latest');
});
});
describe('install', () => {
it('installs path from local cache', async () => {
cache.fromLocalCache.mockResolvedValue('/cache/path');
const expoPath = await install.install({ version: '3.0.10', packager: 'npm' });
expect(expoPath).toBe('/cache/path/node_modules/.bin');
cache.fromLocalCache.mockResolvedValue(join('cache', 'path'));
const expoPath = await install.install({ package: 'expo-cli', version: '3.0.10', packager: 'npm' });
expect(expoPath).toBe(join('cache', 'path', 'node_modules', '.bin'));
});
it('installs path from packager and cache it locally', async () => {
utils.setEnv('RUNNER_TEMP', '/temp/path');
utils.setEnv('RUNNER_TEMP', join('temp', 'path'));
cache.fromLocalCache.mockResolvedValue(undefined);
cache.toLocalCache.mockResolvedValue('/cache/path');
const expoPath = await install.install({ version: '3.0.10', packager: 'npm' });
expect(expoPath).toBe('/cache/path/node_modules/.bin');
expect(cache.toLocalCache).toBeCalledWith('/temp/path', '3.0.10');
cache.toLocalCache.mockResolvedValue(join('cache', 'path'));
const expoPath = await install.install({ package: 'expo-cli', version: '3.0.10', packager: 'npm' });
expect(expoPath).toBe(join('cache', 'path', 'node_modules', '.bin'));
expect(cache.toLocalCache).toBeCalledWith(join('temp', 'path'), { package: 'expo-cli', version: '3.0.10', packager: 'npm' });
utils.restoreEnv();
});
it('installs path from remote cache', async () => {
cache.fromLocalCache.mockResolvedValue(undefined);
cache.fromRemoteCache.mockResolvedValue('/cache/path');
registry.manifest.mockResolvedValue({ version: '3.20.0' });
const expoPath = await install.install({ version: '3.20.1', packager: 'npm', cache: true });
expect(expoPath).toBe('/cache/path/node_modules/.bin');
expect(cache.fromRemoteCache).toBeCalledWith('3.20.0', 'npm', undefined);
cache.fromRemoteCache.mockResolvedValue(join('cache', 'path'));
const expoPath = await install.install({ package: 'eas-cli', version: '4.2.0', packager: 'yarn', cache: true });
expect(expoPath).toBe(join('cache', 'path', 'node_modules', '.bin'));
expect(cache.fromRemoteCache).toBeCalledWith({ package: 'eas-cli', version: '4.2.0', packager: 'yarn', cache: true });
});
it('installs path from packager and cache it remotely', async () => {
utils.setEnv('RUNNER_TEMP', '/temp/path');
utils.setEnv('RUNNER_TEMP', join('temp', 'path'));
cache.fromLocalCache.mockResolvedValue(undefined);
cache.fromRemoteCache.mockResolvedValue(undefined);
cache.toLocalCache.mockResolvedValue('/cache/path');
registry.manifest.mockResolvedValue({ version: '3.20.1' });
const expoPath = await install.install({ version: '3.20.1', packager: 'npm', cache: true });
expect(expoPath).toBe('/cache/path/node_modules/.bin');
expect(cache.toRemoteCache).toBeCalledWith('/cache/path', '3.20.1', 'npm', undefined);
cache.toLocalCache.mockResolvedValue(join('cache', 'path'));
const expoPath = await install.install({ package: 'expo-cli', version: '3.20.1', packager: 'npm', cache: true });
expect(expoPath).toBe(join('cache', 'path', 'node_modules', '.bin'));
expect(cache.toRemoteCache).toBeCalledWith(join('cache', 'path'), { package: 'expo-cli', version: '3.20.1', packager: 'npm', cache: true });
utils.restoreEnv();
});
});
describe('fromPackager', () => {
it('resolves tool path', async () => {
await install.fromPackager('3.0.10', 'npm');
await install.fromPackager({ package: 'expo-cli', version: '3.0.10', packager: 'npm' });
expect(io.which).toBeCalledWith('npm');
});
it('creates temporary folder', async () => {
utils.setEnv('RUNNER_TEMP', '/temp/path');
await install.fromPackager('latest', 'yarn');
expect(io.mkdirP).toBeCalledWith('/temp/path');
utils.setEnv('RUNNER_TEMP', join('temp', 'path'));
await install.fromPackager({ package: 'eas-cli', version: 'latest', packager: 'yarn' });
expect(io.mkdirP).toBeCalledWith(join('temp', 'path'));
utils.restoreEnv();
});
it('installs expo with tool', async () => {
utils.setEnv('RUNNER_TEMP', '/temp/path');
utils.setEnv('RUNNER_TEMP', join('temp', 'path'));
io.which.mockResolvedValue('npm');
const expoPath = await install.fromPackager('beta', 'npm');
expect(expoPath).toBe('/temp/path');
const expoPath = await install.fromPackager({ package: 'eas-cli', version: 'beta', packager: 'npm' });
expect(expoPath).toBe(join('temp', 'path'));
expect(cli.exec).toBeCalled();
expect(cli.exec.mock.calls[0][0]).toBe('npm');
expect(cli.exec.mock.calls[0][1]).toStrictEqual(['add', 'expo-cli@beta']);
expect(cli.exec.mock.calls[0][2]).toMatchObject({ cwd: '/temp/path' });
expect(cli.exec.mock.calls[0][1]).toStrictEqual(['add', 'eas-cli@beta']);
expect(cli.exec.mock.calls[0][2]).toMatchObject({ cwd: join('temp', 'path') });
utils.restoreEnv();
});
});
+146 -55
View File
@@ -1,85 +1,176 @@
const core = { addPath: jest.fn(), getInput: jest.fn() };
const core = {
addPath: jest.fn(),
getInput: jest.fn(),
group: (message: string, action: () => Promise<any>) => action(),
info: jest.fn(),
};
const exec = { exec: jest.fn() };
const expo = { authenticate: jest.fn() };
const install = { install: jest.fn() };
const system = { patchWatchers: jest.fn() };
const tools = {
getBoolean: jest.fn((v, d) => v ? v === 'true' : d),
getBinaryName: jest.fn(v => v.replace('-cli', '')),
resolveVersion: jest.fn((n, v) => v),
maybeAuthenticate: jest.fn(),
maybePatchWatchers: jest.fn(),
};
jest.mock('@actions/core', () => core);
jest.mock('@actions/exec', () => exec);
jest.mock('../src/expo', () => expo);
jest.mock('../src/tools', () => tools);
jest.mock('../src/install', () => install);
jest.mock('../src/system', () => system);
import { run } from '../src/run';
interface MockInputProps {
version?: string;
packager?: string;
username?: string;
password?: string;
patchWatchers?: string;
cache?: string;
cacheKey?: string;
}
const mockInput = (props: MockInputProps = {}) => {
// fix: kind of dirty workaround for missing "mock 'value' based on arguments"
const input = (name: string) => {
switch (name) {
case 'expo-version': return props.version || '';
case 'expo-packager': return props.packager || '';
case 'expo-username': return props.username || '';
case 'expo-password': return props.password || '';
case 'expo-patch-watchers': return props.patchWatchers || '';
case 'expo-cache': return props.cache || '';
case 'expo-cache-key': return props.cacheKey || '';
default: return '';
}
};
// eslint-disable-next-line @typescript-eslint/no-explicit-any
core.getInput = input as any;
};
describe('run', () => {
it('installs latest expo-cli with yarn by default', async () => {
await run();
expect(install.install).toBeCalledWith({ version: 'latest', packager: 'yarn', cache: false });
});
it('installs provided version expo-cli with npm', async () => {
mockInput({ version: '3.0.10', packager: 'npm' });
await run();
expect(install.install).toBeCalledWith({ version: '3.0.10', packager: 'npm', cache: false });
});
it('installs path to global path', async () => {
install.install.mockResolvedValue('/expo/install/path');
await run();
expect(core.addPath).toBeCalledWith('/expo/install/path');
});
it('patches the system when set to true', async () => {
mockInput({ patchWatchers: 'true' });
await run();
expect(system.patchWatchers).toHaveBeenCalled();
expect(tools.maybePatchWatchers).toHaveBeenCalled();
});
it('patches the system when not set', async () => {
mockInput({ patchWatchers: '' });
await run();
expect(system.patchWatchers).toHaveBeenCalled();
expect(tools.maybePatchWatchers).toHaveBeenCalled();
});
it('skips the system patch when set to false', async () => {
mockInput({ patchWatchers: 'false' });
await run();
expect(system.patchWatchers).not.toHaveBeenCalled();
expect(tools.maybePatchWatchers).not.toHaveBeenCalled();
});
it('authenticates with provided credentials', async () => {
mockInput({ username: 'bycedric', password: 'mypassword', patchWatchers: 'false' });
await run();
expect(expo.authenticate).toBeCalledWith('bycedric', 'mypassword');
expect(tools.maybeAuthenticate).toBeCalledWith({ username: 'bycedric', password: 'mypassword' });
});
it('authenticates with provided token', async () => {
mockInput({ token: 'ABC123', patchWatchers: 'false' });
await run();
expect(tools.maybeAuthenticate).toBeCalledWith({ token: 'ABC123' });
});
['expo', 'eas'].forEach(cliName => {
const packageName = `${cliName}-cli`;
describe(packageName, () => {
it(`skips installation without \`${cliName}-version\``, async () => {
mockInput();
await run();
expect(install.install).not.toBeCalledWith({ package: packageName });
});
it('installs with yarn by default', async () => {
mockInput({ [`${cliName}Version`]: 'latest' });
await run();
expect(install.install).toBeCalledWith({
package:
packageName,
version: 'latest',
packager: 'yarn',
cache: false,
});
});
it('installs provided version with npm', async () => {
mockInput({ [`${cliName}Version`]: '3.0.10', packager: 'npm' });
await run();
expect(install.install).toBeCalledWith({
package: packageName,
version: '3.0.10',
packager: 'npm',
cache: false,
});
});
it('installs with yarn and cache enabled', async () => {
mockInput({
packager: 'yarn',
[`${cliName}Version`]: '4.2.0',
[`${cliName}Cache`]: 'true',
});
await run();
expect(install.install).toBeCalledWith({
package: packageName,
version: '4.2.0',
packager: 'yarn',
cache: true,
});
});
it('installs with yarn and custom cache key', async () => {
mockInput({
packager: 'yarn',
[`${cliName}Version`]: '4.2.0',
[`${cliName}Cache`]: 'true',
[`${cliName}CacheKey`]: 'custom-key'
});
await run();
expect(install.install).toBeCalledWith({
package: packageName,
version: '4.2.0',
packager: 'yarn',
cache: true,
cacheKey: 'custom-key',
});
});
it('installs path to global path', async () => {
install.install.mockResolvedValue(`/${cliName}/install/path`);
await run();
expect(core.addPath).toBeCalledWith(`/${cliName}/install/path`);
});
});
});
});
interface MockInputProps {
expoVersion?: string;
expoCache?: string;
expoCacheKey?: string;
easVersion?: string;
easCache?: string;
easCacheKey?: string;
packager?: string;
token?: string;
username?: string;
password?: string;
patchWatchers?: string;
}
function mockInput(props: MockInputProps = {}) {
// fix: kind of dirty workaround for missing "mock 'value' based on arguments"
const input = (name: string) => {
switch (name) {
case 'expo-version':
return props.expoVersion || '';
case 'expo-cache':
return props.expoCache || '';
case 'expo-cache-key':
return props.expoCacheKey || '';
case 'eas-version':
return props.easVersion || '';
case 'eas-cache':
return props.easCache || '';
case 'eas-cache-key':
return props.easCacheKey || '';
case 'packager':
return props.packager || '';
case 'token':
return props.token || '';
case 'username':
return props.username || '';
case 'password':
return props.password || '';
case 'patch-watchers':
return props.patchWatchers || '';
default:
return '';
}
};
// eslint-disable-next-line @typescript-eslint/no-explicit-any
core.getInput = input as any;
}
-57
View File
@@ -1,57 +0,0 @@
import * as core from '@actions/core';
import * as cli from '@actions/exec';
import * as system from '../src/system';
import * as utils from './utils';
describe('patchWatchers', () => {
const spy = {
info: jest.spyOn(core, 'info').mockImplementation(),
warning: jest.spyOn(core, 'warning').mockImplementation(),
exec: jest.spyOn(cli, 'exec').mockImplementation(),
};
afterEach(() => {
utils.restorePlatform();
});
it('increses fs inotify settings with sysctl', async () => {
utils.setPlatform('linux');
await system.patchWatchers();
expect(spy.exec).toBeCalledWith('sudo sysctl fs.inotify.max_user_instances=524288');
expect(spy.exec).toBeCalledWith('sudo sysctl fs.inotify.max_user_watches=524288');
expect(spy.exec).toBeCalledWith('sudo sysctl fs.inotify.max_queued_events=524288');
expect(spy.exec).toBeCalledWith('sudo sysctl -p');
});
it('warns for unsuccessful patches', async () => {
const error = new Error('Something went wrong');
spy.exec.mockRejectedValueOnce(error);
utils.setPlatform('linux');
await system.patchWatchers();
expect(core.warning).toBeCalledWith(expect.stringContaining('can\'t patch watchers'));
expect(core.warning).toBeCalledWith(
expect.stringContaining('https://github.com/expo/expo-github-action/issues/20')
);
});
it('skips on windows platform', async () => {
utils.setPlatform('win32');
await system.patchWatchers();
expect(spy.info).toBeCalledWith(expect.stringContaining('Skipping'));
expect(spy.exec).not.toHaveBeenCalled();
});
it('skips on macos platform', async () => {
utils.setPlatform('darwin');
await system.patchWatchers();
expect(spy.info).toBeCalledWith(expect.stringContaining('Skipping'));
expect(spy.exec).not.toHaveBeenCalled();
});
it('runs on linux platform', async () => {
utils.setPlatform('linux');
await system.patchWatchers();
expect(spy.info).toBeCalledWith(expect.stringContaining('Patching'));
expect(spy.exec).toHaveBeenCalled();
});
});
+344
View File
@@ -0,0 +1,344 @@
const registry = { manifest: jest.fn() };
jest.mock('libnpm', () => registry);
import * as core from '@actions/core';
import * as cli from '@actions/exec';
import * as tools from '../src/tools';
import * as utils from './utils';
describe(tools.getBoolean, () => {
it('rreturns false for empty strings by default', () => {
expect(tools.getBoolean('')).toBeFalsy();
});
it('returns true for empty strings with default set to true', () => {
expect(tools.getBoolean('', true)).toBeTruthy();
});
it('returns true for `true` strings by default', () => {
expect(tools.getBoolean('true')).toBeTruthy();
});
it('returns false for `false` strings with default set to false', () => {
expect(tools.getBoolean('false', false)).toBeFalsy();
});
it('returns false for `false` strings with default set to true', () => {
expect(tools.getBoolean('false', true)).toBeFalsy();
});
});
describe(tools.getBinaryName, () => {
it('returns expo for `expo-cli`', () => {
expect(tools.getBinaryName('expo-cli')).toBe('expo');
});
it('returns eas for `eas-cli`', () => {
expect(tools.getBinaryName('eas-cli')).toBe('eas');
});
it('returns eas.cmd for `eas-cli` for windows', () => {
expect(tools.getBinaryName('eas-cli', true)).toBe('eas.cmd');
});
});
describe(tools.resolveVersion, () => {
it('fetches exact version of expo-cli', async () => {
registry.manifest.mockResolvedValue({ version: '3.0.10' });
expect(await tools.resolveVersion('expo-cli', 'latest')).toBe('3.0.10');
expect(registry.manifest).toBeCalledWith('expo-cli@latest');
});
it('fetches exact version of eas-cli', async () => {
registry.manifest.mockResolvedValue({ version: '4.2.0' });
expect(await tools.resolveVersion('eas-cli', 'latest')).toBe('4.2.0');
expect(registry.manifest).toBeCalledWith('eas-cli@latest');
});
});
describe(tools.maybeAuthenticate, () => {
const token = 'ABC123';
const username = 'bycedric';
const password = 'mypassword';
describe('with token', () => {
let spy: { [key: string]: jest.SpyInstance } = {};
beforeEach(() => {
spy = {
exportVariable: jest.spyOn(core, 'exportVariable').mockImplementation(),
exec: jest.spyOn(cli, 'exec').mockImplementation(),
info: jest.spyOn(core, 'info').mockImplementation(),
};
});
afterAll(() => {
spy.exportVariable.mockRestore();
spy.exec.mockRestore();
spy.info.mockRestore();
});
it('skips authentication without token', async () => {
await tools.maybeAuthenticate();
expect(spy.exec).not.toBeCalled();
expect(spy.info).toBeCalledWith(expect.stringContaining('Skipping authentication'));
});
it('executes whoami command with token through environment', async () => {
utils.setEnv('TEST_INCLUDED', 'hellyeah');
await tools.maybeAuthenticate({ token, cli: 'expo-cli' });
expect(spy.exec).toBeCalled();
expect(spy.exec.mock.calls[0][1]).toStrictEqual(['whoami']);
expect(spy.exec.mock.calls[0][2]).toMatchObject({
env: {
TEST_INCLUDED: 'hellyeah',
EXPO_TOKEN: token,
},
});
utils.restoreEnv();
});
it('fails when token is incorrect', async () => {
const error = new Error('Not logged in');
spy.exec.mockRejectedValue(error);
await expect(tools.maybeAuthenticate({ token, cli: 'expo-cli' })).rejects.toBe(error);
});
it('skips validation without cli', async () => {
await tools.maybeAuthenticate({ token });
expect(spy.exec).not.toBeCalled();
expect(spy.info).toBeCalledWith(expect.stringContaining('Skipping token validation'));
});
it('executes whoami command with `expo` on macos', async () => {
utils.setPlatform('darwin');
await tools.maybeAuthenticate({ token, cli: 'expo-cli' });
expect(spy.exec).toBeCalled();
expect(spy.exec.mock.calls[0][0]).toBe('expo');
utils.restorePlatform();
});
it('executes whoami command with `eas` on ubuntu', async () => {
utils.setPlatform('linux');
await tools.maybeAuthenticate({ token, cli: 'eas-cli' });
expect(spy.exec).toBeCalled();
expect(spy.exec.mock.calls[0][0]).toBe('eas');
utils.restorePlatform();
});
it('executes whoami command with `expo.cmd` on windows', async () => {
utils.setPlatform('win32');
await tools.maybeAuthenticate({ token, cli: 'expo-cli' });
expect(spy.exec).toBeCalled();
expect(spy.exec.mock.calls[0][0]).toBe('expo.cmd');
utils.restorePlatform();
});
});
describe('credentials', () => {
let spy: { [key: string]: jest.SpyInstance } = {};
beforeEach(() => {
spy = {
exec: jest.spyOn(cli, 'exec').mockImplementation(),
info: jest.spyOn(core, 'info').mockImplementation(),
warning: jest.spyOn(core, 'warning').mockImplementation(),
};
});
afterAll(() => {
spy.exec.mockRestore();
spy.info.mockRestore();
spy.warning.mockRestore();
});
it('skips authentication without cli', async () => {
await tools.maybeAuthenticate({});
expect(spy.exec).not.toBeCalled();
expect(spy.info).toBeCalledWith(expect.stringContaining('Skipping authentication'));
});
it('skips authentication without credentials', async () => {
await tools.maybeAuthenticate({ cli: 'expo-cli' });
expect(spy.exec).not.toBeCalled();
expect(spy.info).toBeCalledWith(expect.stringContaining('Skipping authentication'));
});
it('skips authentication without password', async () => {
await tools.maybeAuthenticate({ username, cli: 'expo-cli' });
expect(spy.exec).not.toBeCalled();
expect(spy.info).toBeCalledWith(expect.stringContaining('Skipping authentication'));
});
it('skips authentication with credentials for eas-cli', async () => {
await tools.maybeAuthenticate({ username, password, cli: 'eas-cli' });
expect(spy.exec).not.toBeCalled();
expect(spy.warning).toBeCalledWith(expect.stringContaining('Skipping authentication'));
});
it('executes login command with password through environment', async () => {
utils.setEnv('TEST_INCLUDED', 'hellyeah');
await tools.maybeAuthenticate({ username, password, cli: 'expo-cli' })
expect(spy.exec).toBeCalled();
expect(spy.exec.mock.calls[0][1]).toStrictEqual(['login', `--username=${username}`]);
expect(spy.exec.mock.calls[0][2]).toMatchObject({
env: {
TEST_INCLUDED: 'hellyeah',
EXPO_CLI_PASSWORD: password,
},
});
utils.restoreEnv();
});
it('fails when credentials are incorrect', async () => {
const error = new Error('Invalid username/password. Please try again.');
spy.exec.mockRejectedValue(error);
await expect(tools.maybeAuthenticate({ username, password, cli: 'expo-cli' }))
.rejects
.toBe(error);
});
it('executes login command with `expo` on macos', async () => {
utils.setPlatform('darwin');
await tools.maybeAuthenticate({ username, password, cli: 'expo-cli' });
expect(spy.exec).toBeCalled();
expect(spy.exec.mock.calls[0][0]).toBe('expo');
utils.restorePlatform();
});
it('executes login command with `expo` on ubuntu', async () => {
utils.setPlatform('linux');
await tools.maybeAuthenticate({ username, password, cli: 'expo-cli' });
expect(spy.exec).toBeCalled();
expect(spy.exec.mock.calls[0][0]).toBe('expo');
utils.restorePlatform();
});
it('executes login command with `expo.cmd` on windows', async () => {
utils.setPlatform('win32');
await tools.maybeAuthenticate({ username, password, cli: 'expo-cli' });
expect(spy.exec).toBeCalled();
expect(spy.exec.mock.calls[0][0]).toBe('expo.cmd');
utils.restorePlatform();
});
});
});
describe(tools.maybePatchWatchers, () => {
let spy: { [key: string]: jest.SpyInstance } = {};
beforeEach(() => {
spy = {
info: jest.spyOn(core, 'info').mockImplementation(),
warning: jest.spyOn(core, 'warning').mockImplementation(),
exec: jest.spyOn(cli, 'exec').mockImplementation(),
};
});
afterEach(() => {
utils.restorePlatform();
});
afterAll(() => {
spy.info.mockRestore();
spy.warning.mockRestore();
spy.exec.mockRestore();
});
it('increses fs inotify settings with sysctl', async () => {
utils.setPlatform('linux');
await tools.maybePatchWatchers();
expect(spy.exec).toBeCalledWith('sudo sysctl fs.inotify.max_user_instances=524288');
expect(spy.exec).toBeCalledWith('sudo sysctl fs.inotify.max_user_watches=524288');
expect(spy.exec).toBeCalledWith('sudo sysctl fs.inotify.max_queued_events=524288');
expect(spy.exec).toBeCalledWith('sudo sysctl -p');
});
it('warns for unsuccessful patches', async () => {
const error = new Error('Something went wrong');
spy.exec.mockRejectedValueOnce(error);
utils.setPlatform('linux');
await tools.maybePatchWatchers();
expect(core.warning).toBeCalledWith(expect.stringContaining("can't patch watchers"));
expect(core.warning).toBeCalledWith(
expect.stringContaining('https://github.com/expo/expo-github-action/issues/20')
);
});
it('skips on windows platform', async () => {
utils.setPlatform('win32');
await tools.maybePatchWatchers();
expect(spy.info).toBeCalledWith(expect.stringContaining('Skipping'));
expect(spy.exec).not.toHaveBeenCalled();
});
it('skips on macos platform', async () => {
utils.setPlatform('darwin');
await tools.maybePatchWatchers();
expect(spy.info).toBeCalledWith(expect.stringContaining('Skipping'));
expect(spy.exec).not.toHaveBeenCalled();
});
it('runs on linux platform', async () => {
utils.setPlatform('linux');
await tools.maybePatchWatchers();
expect(spy.info).toBeCalledWith(expect.stringContaining('Patching'));
expect(spy.exec).toHaveBeenCalled();
});
});
describe(tools.maybeWarnForUpdate, () => {
let spy: { [key: string]: jest.SpyInstance } = {};
beforeEach(() => {
spy = { warning: jest.spyOn(core, 'warning').mockImplementation() };
});
afterAll(() => {
spy.warning.mockRestore();
});
it('is silent when major version is up to date', async () => {
registry.manifest
.mockResolvedValueOnce({ version: '4.1.0' })
.mockResolvedValueOnce({ version: '4.0.1'});
await tools.maybeWarnForUpdate('eas-cli');
expect(spy.warning).not.toBeCalled();
})
it('warns when major version is outdated', async () => {
registry.manifest
.mockResolvedValueOnce({ version: '4.1.0' })
.mockResolvedValueOnce({ version: '3.0.1'});
await tools.maybeWarnForUpdate('expo-cli');
expect(spy.warning).toBeCalledWith('There is a new major version available of the Expo CLI (4.1.0)');
expect(spy.warning).toBeCalledWith('If you run into issues, try upgrading your workflow to "expo-version: 4.x"');
})
});
describe(tools.handleError, () => {
let spy: { [key: string]: jest.SpyInstance } = {};
beforeEach(() => {
spy = { setFailed: jest.spyOn(core, 'setFailed').mockImplementation() };
});
afterAll(() => {
spy.setFailed.mockRestore();
});
it('marks the job as failed with expo-cli', async () => {
const error = new Error('test');
registry.manifest.mockResolvedValue('4.0.0');
await tools.handleError('expo-cli', error);
expect(core.setFailed).toBeCalledWith(error);
});
it('fails with original error when update warning failed', async () => {
const error = new Error('test');
registry.manifest.mockRejectedValue(new Error('npm issue'));
await tools.handleError('eas-cli', error);
expect(core.setFailed).toBeCalledWith(error);
});
});
+4 -4
View File
@@ -5,14 +5,14 @@ const originalPlatform = process.platform;
* Change the node platform for testing purposes.
* With this you can fake the `process.platform`.
*/
export function setPlatform(platform: NodeJS.Platform) {
export function setPlatform(platform: NodeJS.Platform): void {
Object.defineProperty(process, 'platform', { value: platform });
}
/**
* Revert the platform to the original one.
*/
export function restorePlatform() {
export function restorePlatform(): void {
setPlatform(originalPlatform);
}
@@ -22,13 +22,13 @@ const originalEnv = { ...process.env };
/**
* Change the environment variable for testing purposes.
*/
export function setEnv(name: string, value: string) {
export function setEnv(name: string, value: string): void {
process.env[name] = value;
}
/**
* Revert the environment variable changes.
*/
export function restoreEnv() {
export function restoreEnv(): void {
process.env = originalEnv;
}
+3 -8
View File
@@ -1,17 +1,12 @@
{
"extends": "./node_modules/@tsconfig/node14/tsconfig.json",
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"lib": [
"es6"
],
"outDir": "./build",
"rootDir": "./src",
"strict": true,
"noImplicitAny": false,
"esModuleInterop": true
"noImplicitAny": false
},
"exclude": [
"build",
"node_modules",
"tests/**"
]
+3848 -2205
View File
File diff suppressed because it is too large. Load diff