mirror of
https://github.com/expo/expo-github-action.git
synced 2026-11-15 17:32:45 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5d3c1cdff4 | ||
|
|
ce1c6b612a | ||
|
|
b807fa603f | ||
|
|
1010edb8c8 | ||
|
|
b80de3494e | ||
|
|
f773f9c85c | ||
|
|
1c36889886 | ||
|
|
ce3c32e185 | ||
|
|
050b7019f7 | ||
|
|
404bd09c6f | ||
|
|
d3602b92b2 | ||
|
|
6ac67f03d0 | ||
|
|
b8a49f4d14 | ||
|
|
84e06132b2 | ||
|
|
71dfeab7a0 | ||
|
|
f6dba4e7ce | ||
|
|
586d2b1bea | ||
|
|
39cd204496 |
No files matched your search
@@ -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
|
||||
+11
-10
@@ -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,6 +18,7 @@ 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',
|
||||
|
||||
@@ -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: [12, 14]
|
||||
os:
|
||||
- macos-latest
|
||||
- ubuntu-latest
|
||||
- windows-latest
|
||||
include:
|
||||
- node: 12
|
||||
os: macos-latest
|
||||
checkUpToDate: true
|
||||
- node: 12
|
||||
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
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"printWidth": 120,
|
||||
"tabWidth": 2,
|
||||
"singleQuote": true,
|
||||
"jsxBracketSameLine": true,
|
||||
"trailingComma": "es5",
|
||||
"arrowParens": "avoid"
|
||||
}
|
||||
@@ -1,3 +1,44 @@
|
||||
## [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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,37 +1,59 @@
|
||||
# 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/master.svg?style=flat-square" alt="builds" />
|
||||
</a>
|
||||
<a href="https://github.com/expo/expo-github-action/blob/master/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>
|
||||
—
|
||||
<a href="https://github.com/expo/expo-github-action#example-workflows"><b>Examples</b></a>
|
||||
—
|
||||
<a href="https://github.com/expo/expo-github-action#things-to-know"><b>Caveats</b></a>
|
||||
—
|
||||
<a href="https://github.com/expo/expo-github-action/blob/master/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 the [Expo CLI][link-expo-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-username` | - | The username of your Expo account _(e.g. `bycedric`)_
|
||||
`expo-token` | - | The token of your Expo account _(e.g. [`${{ secrets.EXPO_TOKEN }}`][link-actions-secrets])_
|
||||
`expo-password` | - | The password of your Expo account _(e.g. [`${{ secrets.EXPO_CLI_PASSWORD }}`][link-actions-secrets])_
|
||||
`expo-version` | `latest` | The Expo CLI version to use, can be any [SemVer][link-semver-playground]. _(e.g. `3.x`)_
|
||||
`expo-packager` | `yarn` | The package manager to install the CLI with. _(e.g. `npm`)_
|
||||
`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**)_
|
||||
`expo-patch-watchers` | `true` | If it should [patch the `fs.inotify.` limits](#enospc-errors-on-linux).
|
||||
|
||||
> Never hardcode `expo-token` or `expo-password` in your workflow, use [secrets][link-actions-secrets] to store them.
|
||||
|
||||
> It's also recommended to set the `expo-version` to avoid breaking changes when a new major version is released.
|
||||
|
||||
> `expo-token` is available from Expo CLI `3.25.0`.
|
||||
|
||||
> 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].
|
||||
|
||||
## Example workflows
|
||||
|
||||
@@ -43,6 +65,7 @@ You can read more about this in the [GitHub Actions documentation][link-actions]
|
||||
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)
|
||||
6. [Authenticate using an Expo token](#authenticate-using-an-expo-token)
|
||||
|
||||
### Publish on any push to master
|
||||
|
||||
@@ -61,7 +84,7 @@ 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
|
||||
@@ -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)
|
||||
|
||||
@@ -93,7 +116,7 @@ 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
|
||||
@@ -110,8 +133,8 @@ jobs:
|
||||
### 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,7 +144,7 @@ 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
|
||||
@@ -143,7 +166,6 @@ 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.
|
||||
|
||||
@@ -159,7 +181,7 @@ 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 }}
|
||||
@@ -174,8 +196,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,7 +208,7 @@ 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
|
||||
@@ -199,52 +220,75 @@ jobs:
|
||||
- run: expo build:web
|
||||
```
|
||||
|
||||
### Authenticate using an Expo token
|
||||
|
||||
Instead of username and password, you can also authenticate using a token.
|
||||
This might help increasing security and avoids adding username and password to your repository secrets.
|
||||
|
||||
```yml
|
||||
name: Expo Publish
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
jobs:
|
||||
publish:
|
||||
name: Install and publish
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 12.x
|
||||
- uses: expo/expo-github-action@v5
|
||||
with:
|
||||
expo-version: 3.x
|
||||
expo-token: ${{ secrets.EXPO_TOKEN }}
|
||||
- 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`.
|
||||
As of writing, GitHub doesn't provide a (remote) cache for 3rd party actions.
|
||||
That's why we implemented the [Cypress fork of the `actions/cache`][link-actions-cache-cypress].
|
||||
With this, you can opt-in to caching the Expo CLI install, making it a lot faster.
|
||||
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].
|
||||
|
||||
### 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`.
|
||||
|
||||
## 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: <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-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-semver-playground]: https://semver.npmjs.com/
|
||||
+3
-1
@@ -8,12 +8,14 @@ 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-token:
|
||||
description: Your Expo token, for authentication. (use with secrets)
|
||||
expo-password:
|
||||
description: Your Expo password, for authentication. (use with secrets)
|
||||
expo-packager:
|
||||
|
||||
+3306
-1280
File diff suppressed because it is too large.
Load diff
+18
-16
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"private": true,
|
||||
"name": "expo-github-action",
|
||||
"version": "5.1.0",
|
||||
"version": "5.3.0",
|
||||
"description": "Expo CLI in your GitHub Actions workflow",
|
||||
"main": "build/index.js",
|
||||
"repository": {
|
||||
@@ -17,33 +17,35 @@
|
||||
"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"
|
||||
},
|
||||
"dependencies": {
|
||||
"@actions/cache": "github:cypress-io/github-actions-cache#8bec6cc",
|
||||
"@actions/core": "^1.2.4",
|
||||
"@actions/core": "^1.2.6",
|
||||
"@actions/exec": "^1.0.4",
|
||||
"@actions/io": "^1.0.2",
|
||||
"@actions/tool-cache": "^1.3.4",
|
||||
"@actions/tool-cache": "^1.5.5",
|
||||
"libnpm": "^3.0.1"
|
||||
},
|
||||
"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",
|
||||
"@types/jest": "^26.0.4",
|
||||
"@types/node": "^12.12.49",
|
||||
"@typescript-eslint/eslint-plugin": "^3.6.1",
|
||||
"@typescript-eslint/parser": "^3.6.1",
|
||||
"@zeit/ncc": "^0.22.3",
|
||||
"eslint": "^7.4.0",
|
||||
"eslint-plugin-jest": "^23.18.0",
|
||||
"husky": "^4.2.5",
|
||||
"jest": "^26.0.1",
|
||||
"jest-circus": "^26.0.1",
|
||||
"ts-jest": "^25.5.0",
|
||||
"typescript": "^3.8.3"
|
||||
"jest-circus": "^26.1.0",
|
||||
"rimraf": "^3.0.2",
|
||||
"ts-jest": "^26.1.2",
|
||||
"typescript": "^3.9.6"
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "npm run build && git add build"
|
||||
"pre-commit": "yarn build && git add build"
|
||||
}
|
||||
}
|
||||
}
|
||||
+50
-5
@@ -1,20 +1,24 @@
|
||||
import * as core from '@actions/core';
|
||||
import * as cli from '@actions/exec';
|
||||
|
||||
type AuthOptions = {
|
||||
token?: string;
|
||||
username?: string;
|
||||
password?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
export async function authWithCredentials(username?: string, password?: string) {
|
||||
if (!username || !password) {
|
||||
return core.info('Skipping authentication, `expo-username` and/or `expo-password` not set...');
|
||||
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';
|
||||
const bin = process.platform === 'win32' ? 'expo.cmd' : 'expo';
|
||||
|
||||
await cli.exec(bin, ['login', `--username=${username}`], {
|
||||
env: {
|
||||
@@ -23,3 +27,44 @@ export async function authenticate(username: string, password: string) {
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Authenticate with Expo using `EXPO_TOKEN`.
|
||||
* This exports the EXPO_TOKEN environment variable for all future steps within the workflow.
|
||||
* It also double-checks if this token is valid and for what user, by running `expo whoami`.
|
||||
*
|
||||
* @see https://github.com/actions/toolkit/blob/905b2c7b0681b11056141a60055f1ba77358b7e9/packages/core/src/core.ts#L39
|
||||
*/
|
||||
export async function authWithToken(token?: string) {
|
||||
if (!token) {
|
||||
return core.info('Skipping authentication: `expo-token` 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, ['whoami'], {
|
||||
env: {
|
||||
...process.env,
|
||||
EXPO_TOKEN: token,
|
||||
},
|
||||
});
|
||||
|
||||
core.exportVariable('EXPO_TOKEN', token);
|
||||
}
|
||||
|
||||
/**
|
||||
* Authenticate with Expo using either the token or username/password method.
|
||||
* If both of them are set, token has priority.
|
||||
*/
|
||||
export function authenticate(options: AuthOptions) {
|
||||
if (options.token) {
|
||||
return authWithToken(options.token);
|
||||
}
|
||||
|
||||
if (options.username || options.password) {
|
||||
return authWithCredentials(options.username, options.password);
|
||||
}
|
||||
|
||||
core.info('Skipping authentication: `expo-token`, `expo-username`, and/or `expo-password` not set...');
|
||||
}
|
||||
+4
-9
@@ -2,22 +2,17 @@ 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';
|
||||
import { fromLocalCache, fromRemoteCache, toLocalCache, toRemoteCache } from './cache';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const registry = require('libnpm');
|
||||
|
||||
interface InstallConfig {
|
||||
type InstallConfig = {
|
||||
version: string;
|
||||
packager: string;
|
||||
cache?: boolean;
|
||||
cacheKey?: string;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Resolve the provided semver to exact version of `expo-cli`.
|
||||
@@ -44,7 +39,7 @@ export async function install(config: InstallConfig) {
|
||||
}
|
||||
|
||||
if (!root) {
|
||||
root = await fromPackager(exact, config.packager)
|
||||
root = await fromPackager(exact, config.packager);
|
||||
root = await toLocalCache(root, exact);
|
||||
|
||||
if (config.cache) {
|
||||
|
||||
+5
-4
@@ -13,10 +13,11 @@ export async function run() {
|
||||
|
||||
addPath(path);
|
||||
|
||||
await authenticate(
|
||||
getInput('expo-username'),
|
||||
getInput('expo-password'),
|
||||
);
|
||||
await authenticate({
|
||||
token: getInput('expo-token') || undefined,
|
||||
username: getInput('expo-username') || undefined,
|
||||
password: getInput('expo-password') || undefined,
|
||||
});
|
||||
|
||||
const shouldPatchWatchers = getInput('expo-patch-watchers') || 'true';
|
||||
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ export async function patchWatchers() {
|
||||
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("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');
|
||||
}
|
||||
}
|
||||
+36
-22
@@ -1,12 +1,13 @@
|
||||
import os from 'os';
|
||||
import { join } from 'path';
|
||||
import * as remoteCache from '@actions/cache/lib';
|
||||
import * as toolCache from '@actions/tool-cache';
|
||||
import os from 'os';
|
||||
import * as cache from '../src/cache';
|
||||
import * as utils from './utils';
|
||||
|
||||
describe('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');
|
||||
@@ -17,8 +18,8 @@ describe('fromLocalCache', () => {
|
||||
|
||||
describe('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');
|
||||
expect(result).toBe(path);
|
||||
@@ -27,40 +28,45 @@ describe('toLocalCache', () => {
|
||||
});
|
||||
|
||||
describe('fromRemoteCache', () => {
|
||||
const spy = {
|
||||
restore: jest.spyOn(remoteCache, 'restoreCache').mockImplementation(),
|
||||
};
|
||||
let spy: { [key: string]: jest.SpyInstance } = {};
|
||||
|
||||
beforeEach(() => {
|
||||
spy = {
|
||||
restore: jest.spyOn(remoteCache, 'restoreCache').mockImplementation(),
|
||||
};
|
||||
});
|
||||
|
||||
beforeAll(() => {
|
||||
utils.setEnv('RUNNER_TOOL_CACHE', '/cache/path');
|
||||
utils.setEnv('RUNNER_TOOL_CACHE', join('cache', 'path'));
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
utils.restoreEnv();
|
||||
spy.restore.mockRestore();
|
||||
});
|
||||
|
||||
it('restores remote cache with default key', async () => {
|
||||
expect(await cache.fromRemoteCache('3.20.1', '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`,
|
||||
`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(remoteCache.restoreCache).toBeCalledWith(
|
||||
`/cache/path/expo-cli/3.20.0/${os.arch()}`,
|
||||
'custom-cache-key',
|
||||
join('cache', 'path', 'expo-cli', '3.20.0', os.arch()),
|
||||
'custom-cache-key',
|
||||
'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()}`,
|
||||
join('cache', 'path', 'expo-cli', '3.20.1', os.arch())
|
||||
);
|
||||
});
|
||||
|
||||
@@ -72,26 +78,34 @@ describe('fromRemoteCache', () => {
|
||||
});
|
||||
|
||||
describe('toRemoteCache', () => {
|
||||
const spy = {
|
||||
save: jest.spyOn(remoteCache, 'saveCache').mockImplementation(),
|
||||
};
|
||||
let spy: { [key: string]: jest.SpyInstance } = {};
|
||||
|
||||
beforeEach(() => {
|
||||
spy = {
|
||||
save: jest.spyOn(remoteCache, 'saveCache').mockImplementation(),
|
||||
};
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
spy.save.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'), '3.20.1', 'npm')).toBeUndefined();
|
||||
expect(remoteCache.saveCache).toBeCalledWith(
|
||||
'/local/path',
|
||||
`expo-cli-${process.platform}-${os.arch()}-npm-3.20.1`,
|
||||
join('local', 'path'),
|
||||
`expo-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'), '3.20.1', 'yarn', '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'), '3.20.1', 'yarn')).rejects.toBe(error);
|
||||
});
|
||||
});
|
||||
+114
-18
@@ -3,50 +3,146 @@ 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(),
|
||||
};
|
||||
const TOKEN = 'ABC123';
|
||||
const USER = 'bycedric';
|
||||
const PASS = 'mypassword';
|
||||
|
||||
describe('authWithCredentials', () => {
|
||||
let spy: { [key: string]: jest.SpyInstance } = {};
|
||||
|
||||
beforeEach(() => {
|
||||
spy = {
|
||||
exec: jest.spyOn(cli, 'exec').mockImplementation(),
|
||||
info: jest.spyOn(core, 'info').mockImplementation(),
|
||||
};
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
spy.exec.mockRestore();
|
||||
spy.info.mockRestore();
|
||||
});
|
||||
|
||||
it('skips authentication without credentials', async () => {
|
||||
await expo.authenticate('', '');
|
||||
await expo.authWithCredentials();
|
||||
expect(spy.exec).not.toBeCalled();
|
||||
expect(spy.info).toBeCalled();
|
||||
expect(spy.info).toBeCalledWith(expect.stringContaining('Skipping authentication'));
|
||||
});
|
||||
|
||||
it('skips authentication without password', async () => {
|
||||
await expo.authenticate('bycedric', '');
|
||||
await expo.authWithCredentials(USER);
|
||||
expect(spy.exec).not.toBeCalled();
|
||||
expect(spy.info).toBeCalled();
|
||||
expect(spy.info).toBeCalledWith(expect.stringContaining('Skipping authentication'));
|
||||
});
|
||||
|
||||
it('executes login command with password through environment', async () => {
|
||||
utils.setEnv('TEST_INCLUDED', 'hellyeah');
|
||||
await expo.authenticate('bycedric', 'mypassword');
|
||||
await expo.authWithCredentials(USER, PASS);
|
||||
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][1]).toStrictEqual(['login', `--username=${USER}`]);
|
||||
expect(spy.exec.mock.calls[0][2]).toMatchObject({
|
||||
env: {
|
||||
TEST_INCLUDED: 'hellyeah',
|
||||
EXPO_CLI_PASSWORD: 'mypassword',
|
||||
EXPO_CLI_PASSWORD: PASS,
|
||||
},
|
||||
});
|
||||
utils.restoreEnv();
|
||||
});
|
||||
|
||||
it('executes login command with `.cmd` suffix on windows', async () => {
|
||||
it('fails when credentials are incorrect', async () => {
|
||||
const error = new Error('Invalid username/password. Please try again.');
|
||||
spy.exec.mockRejectedValue(error);
|
||||
await expect(expo.authWithCredentials(USER, PASS)).rejects.toBe(error);
|
||||
});
|
||||
|
||||
it('executes login command with `expo` on macos', async () => {
|
||||
utils.setPlatform('darwin');
|
||||
await expo.authWithCredentials(USER, PASS);
|
||||
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 expo.authWithCredentials(USER, PASS);
|
||||
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 expo.authenticate('bycedric', 'mypassword');
|
||||
await expo.authWithCredentials(USER, PASS);
|
||||
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.');
|
||||
describe('authWithToken', () => {
|
||||
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 expo.authWithToken();
|
||||
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 expo.authWithToken(TOKEN);
|
||||
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(expo.authenticate('bycedric', 'incorrect')).rejects.toBe(error);
|
||||
await expect(expo.authWithToken(TOKEN)).rejects.toBe(error);
|
||||
});
|
||||
|
||||
it('executes whoami command with `expo` on macos', async () => {
|
||||
utils.setPlatform('darwin');
|
||||
await expo.authWithToken(TOKEN);
|
||||
expect(spy.exec).toBeCalled();
|
||||
expect(spy.exec.mock.calls[0][0]).toBe('expo');
|
||||
utils.restorePlatform();
|
||||
});
|
||||
|
||||
it('executes whoami command with `expo` on ubuntu', async () => {
|
||||
utils.setPlatform('linux');
|
||||
await expo.authWithToken(TOKEN);
|
||||
expect(spy.exec).toBeCalled();
|
||||
expect(spy.exec.mock.calls[0][0]).toBe('expo');
|
||||
utils.restorePlatform();
|
||||
});
|
||||
|
||||
it('executes whoami command with `expo.cmd` on windows', async () => {
|
||||
utils.setPlatform('win32');
|
||||
await expo.authWithToken(TOKEN);
|
||||
expect(spy.exec).toBeCalled();
|
||||
expect(spy.exec.mock.calls[0][0]).toBe('expo.cmd');
|
||||
utils.restorePlatform();
|
||||
});
|
||||
});
|
||||
+18
-17
@@ -13,6 +13,7 @@ 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';
|
||||
|
||||
@@ -26,39 +27,39 @@ describe('resolve', () => {
|
||||
|
||||
describe('install', () => {
|
||||
it('installs path from local cache', async () => {
|
||||
cache.fromLocalCache.mockResolvedValue('/cache/path');
|
||||
cache.fromLocalCache.mockResolvedValue(join('cache', 'path'));
|
||||
const expoPath = await install.install({ version: '3.0.10', packager: 'npm' });
|
||||
expect(expoPath).toBe('/cache/path/node_modules/.bin');
|
||||
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');
|
||||
cache.toLocalCache.mockResolvedValue(join('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');
|
||||
expect(expoPath).toBe(join('cache', 'path', 'node_modules', '.bin'));
|
||||
expect(cache.toLocalCache).toBeCalledWith(join('temp', 'path'), '3.0.10');
|
||||
utils.restoreEnv();
|
||||
});
|
||||
|
||||
it('installs path from remote cache', async () => {
|
||||
cache.fromLocalCache.mockResolvedValue(undefined);
|
||||
cache.fromRemoteCache.mockResolvedValue('/cache/path');
|
||||
cache.fromRemoteCache.mockResolvedValue(join('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(expoPath).toBe(join('cache', 'path', 'node_modules', '.bin'));
|
||||
expect(cache.fromRemoteCache).toBeCalledWith('3.20.0', 'npm', undefined);
|
||||
});
|
||||
|
||||
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');
|
||||
cache.toLocalCache.mockResolvedValue(join('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);
|
||||
expect(expoPath).toBe(join('cache', 'path', 'node_modules', '.bin'));
|
||||
expect(cache.toRemoteCache).toBeCalledWith(join('cache', 'path'), '3.20.1', 'npm', undefined);
|
||||
utils.restoreEnv();
|
||||
});
|
||||
});
|
||||
@@ -70,21 +71,21 @@ describe('fromPackager', () => {
|
||||
});
|
||||
|
||||
it('creates temporary folder', async () => {
|
||||
utils.setEnv('RUNNER_TEMP', '/temp/path');
|
||||
utils.setEnv('RUNNER_TEMP', join('temp', 'path'));
|
||||
await install.fromPackager('latest', 'yarn');
|
||||
expect(io.mkdirP).toBeCalledWith('/temp/path');
|
||||
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');
|
||||
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][2]).toMatchObject({ cwd: join('temp', 'path') });
|
||||
utils.restoreEnv();
|
||||
});
|
||||
});
|
||||
+26
-9
@@ -15,6 +15,7 @@ import { run } from '../src/run';
|
||||
interface MockInputProps {
|
||||
version?: string;
|
||||
packager?: string;
|
||||
token?: string;
|
||||
username?: string;
|
||||
password?: string;
|
||||
patchWatchers?: string;
|
||||
@@ -26,14 +27,24 @@ 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 '';
|
||||
case 'expo-version':
|
||||
return props.version || '';
|
||||
case 'expo-packager':
|
||||
return props.packager || '';
|
||||
case 'expo-token':
|
||||
return props.token || '';
|
||||
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 '';
|
||||
}
|
||||
};
|
||||
|
||||
@@ -80,6 +91,12 @@ describe('run', () => {
|
||||
it('authenticates with provided credentials', async () => {
|
||||
mockInput({ username: 'bycedric', password: 'mypassword', patchWatchers: 'false' });
|
||||
await run();
|
||||
expect(expo.authenticate).toBeCalledWith('bycedric', 'mypassword');
|
||||
expect(expo.authenticate).toBeCalledWith({ username: 'bycedric', password: 'mypassword' });
|
||||
});
|
||||
|
||||
it('authenticates with provided token', async () => {
|
||||
mockInput({ token: 'ABC123', patchWatchers: 'false' });
|
||||
await run();
|
||||
expect(expo.authenticate).toBeCalledWith({ token: 'ABC123' });
|
||||
});
|
||||
});
|
||||
+16
-6
@@ -4,16 +4,26 @@ 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(),
|
||||
};
|
||||
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 system.patchWatchers();
|
||||
@@ -28,7 +38,7 @@ describe('patchWatchers', () => {
|
||||
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("can't patch watchers"));
|
||||
expect(core.warning).toBeCalledWith(
|
||||
expect.stringContaining('https://github.com/expo/expo-github-action/issues/20')
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user