mirror of
https://github.com/expo/expo-github-action.git
synced 2026-11-15 17:32:45 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1010edb8c8 | ||
|
|
b80de3494e | ||
|
|
f773f9c85c | ||
|
|
1c36889886 | ||
|
|
ce3c32e185 | ||
|
|
050b7019f7 | ||
|
|
404bd09c6f | ||
|
|
d3602b92b2 | ||
|
|
6ac67f03d0 | ||
|
|
b8a49f4d14 | ||
|
|
84e06132b2 | ||
|
|
71dfeab7a0 | ||
|
|
f6dba4e7ce | ||
|
|
586d2b1bea | ||
|
|
39cd204496 | ||
|
|
58185fbf10 | ||
|
|
a4955da38e | ||
|
|
cb490968ad | ||
|
|
42793272a5 | ||
|
|
a7b6ce4357 | ||
|
|
32b5f9cee8 | ||
|
|
4aaf05ff10 | ||
|
|
1cf961c401 | ||
|
|
69801f0afc | ||
|
|
3ac4a96cb4 | ||
|
|
f80ef1f629 | ||
|
|
2de5b8c3bd | ||
|
|
48288d587a | ||
|
|
12f58a21ef | ||
|
|
7776e33fb4 | ||
|
|
4aa2c230ec | ||
|
|
e5677e1fa3 | ||
|
|
68a2de09aa | ||
|
|
831bcb12d3 | ||
|
|
8ff07e0da8 | ||
|
|
16d4b1519f | ||
|
|
cbd9aceff6 | ||
|
|
a80a00b2cd | ||
|
|
38e963b075 | ||
|
|
929a76ca04 | ||
|
|
00692c48ca | ||
|
|
b2929e3879 | ||
|
|
04cd479159 | ||
|
|
cec6e505c1 | ||
|
|
22df52e066 | ||
|
|
98b1bea09b | ||
|
|
e72ddd8c15 | ||
|
|
26c734a57d | ||
|
|
f3bc71a12a | ||
|
|
4766fa83e2 | ||
|
|
caf499b677 | ||
|
|
5cfaee20e5 | ||
|
|
81344e4392 | ||
|
|
89005bc95d | ||
|
|
55b9dc47a8 | ||
|
|
882d5f940b | ||
|
|
cd33736735 | ||
|
|
d1909bbd24 | ||
|
|
d9cb1dbb0e |
No files matched your search
@@ -0,0 +1,16 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_style = tab
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.md]
|
||||
indent_style = space
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[*.yml]
|
||||
indent_size = 2
|
||||
indent_style = space
|
||||
@@ -0,0 +1,26 @@
|
||||
module.exports = {
|
||||
parser: '@typescript-eslint/parser',
|
||||
plugins: [
|
||||
'@typescript-eslint',
|
||||
'jest',
|
||||
],
|
||||
env: {
|
||||
es6: true,
|
||||
'jest/globals': true,
|
||||
node: true,
|
||||
},
|
||||
extends: [
|
||||
'eslint:recommended',
|
||||
'plugin:@typescript-eslint/recommended',
|
||||
],
|
||||
rules: {
|
||||
'@typescript-eslint/explicit-function-return-type': 'off',
|
||||
'@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 @@
|
||||
node_modules
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"printWidth": 120,
|
||||
"tabWidth": 2,
|
||||
"singleQuote": true,
|
||||
"jsxBracketSameLine": true,
|
||||
"trailingComma": "es5",
|
||||
"arrowParens": "avoid"
|
||||
}
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
---
|
||||
language: bash
|
||||
services:
|
||||
- docker
|
||||
env:
|
||||
global:
|
||||
- DOCKER_IMAGE=bycedric/expo-cli
|
||||
- DOCKER_TAG=2
|
||||
script:
|
||||
- docker build base -t $DOCKER_IMAGE:$DOCKER_TAG
|
||||
- docker run -ti --rm $DOCKER_IMAGE:$DOCKER_TAG diagnostics
|
||||
- docker build . -t expo/expo-github-action
|
||||
- docker run -ti --rm expo/expo-github-action diagnostics
|
||||
before_deploy:
|
||||
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
|
||||
- docker tag $DOCKER_IMAGE:$DOCKER_TAG $DOCKER_IMAGE:latest
|
||||
deploy:
|
||||
provider: script
|
||||
script: docker push $DOCKER_IMAGE:$DOCKER_TAG && docker push $DOCKER_IMAGE:latest
|
||||
on:
|
||||
branch: master
|
||||
+149
@@ -1,3 +1,152 @@
|
||||
## [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
|
||||
|
||||
* fail when provided credentials are incorrect ([#43](https://github.com/expo/expo-github-action/pull/43)) ([a7b6ce4](https://github.com/expo/expo-github-action/commit/a7b6ce4))
|
||||
|
||||
### Bug fixes
|
||||
|
||||
* remove custom and add global error handling ([#46](https://github.com/expo/expo-github-action/pull/46)) ([a4955da](https://github.com/expo/expo-github-action/commit/a4955da))
|
||||
|
||||
### Test changes
|
||||
|
||||
* check if build is up to date ([#45](https://github.com/expo/expo-github-action/pull/45)) ([cb49096](https://github.com/expo/expo-github-action/commit/cb49096))
|
||||
* add missing cache unit tests ([#44](https://github.com/expo/expo-github-action/pull/44)) ([4279327](https://github.com/expo/expo-github-action/commit/4279327))
|
||||
|
||||
### Other chores
|
||||
|
||||
* update dependencies and configuration ([#42](https://github.com/expo/expo-github-action/pull/42)) ([32b5f9c](https://github.com/expo/expo-github-action/commit/32b5f9c))
|
||||
* **deps**: bump acorn from 5.7.3 to 5.7.4 ([#37](https://github.com/expo/expo-github-action/pull/37)) ([4aaf05f](https://github.com/expo/expo-github-action/commit/4aaf05f))
|
||||
|
||||
|
||||
## [5.0.0](https://github.com/expo/expo-github-action/compare/4.1.0...5.0.0) (2019-12-31)
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* use yarn by default instead of npm ([#32](https://github.com/expo/expo-github-action/pull/32)) ([2de5b8c3](https://github.com/expo/expo-github-action/commit/2de5b8c))
|
||||
* use ncc to compile scripts ([#31](https://github.com/expo/expo-github-action/pull/31)) ([48288d58](https://github.com/expo/expo-github-action/commit/48288d5))
|
||||
|
||||
### New features
|
||||
|
||||
* implement caching using github actions cache ([#35](https://github.com/expo/expo-github-action/pull/35)) ([69801f0a](https://github.com/expo/expo-github-action/commit/69801f0))
|
||||
|
||||
### Code refactors
|
||||
|
||||
* move index code to run ([#33](https://github.com/expo/expo-github-action/pull/33)) ([f80ef1f6](https://github.com/expo/expo-github-action/commit/f80ef1f))
|
||||
* use yarn by default instead of npm ([#32](https://github.com/expo/expo-github-action/pull/32)) ([2de5b8c3](https://github.com/expo/expo-github-action/commit/2de5b8c))
|
||||
* use ncc to compile scripts ([#31](https://github.com/expo/expo-github-action/pull/31)) ([48288d58](https://github.com/expo/expo-github-action/commit/48288d5))
|
||||
* make logs more visible ([#30](https://github.com/expo/expo-github-action/pull/30)) ([12f58a21](https://github.com/expo/expo-github-action/commit/12f58a2))
|
||||
* update all dependencies to latest versions ([#29](https://github.com/expo/expo-github-action/pull/29)) ([7776e33f](https://github.com/expo/expo-github-action/commit/7776e33))
|
||||
* use circleci instead of github actions ([#28](https://github.com/expo/expo-github-action/pull/28)) ([e5677e1f](https://github.com/expo/expo-github-action/commit/e5677e1))
|
||||
|
||||
### Documentation changes
|
||||
|
||||
* update the default packager value in action ([#34](https://github.com/expo/expo-github-action/pull/34)) ([3ac4a96c](https://github.com/expo/expo-github-action/commit/3ac4a96))
|
||||
|
||||
### Other chores
|
||||
|
||||
* **deps**: bump handlebars from 4.2.0 to 4.5.3 ([#27](https://github.com/expo/expo-github-action/pull/27)) ([4aa2c230](https://github.com/expo/expo-github-action/commit/4aa2c23))
|
||||
|
||||
|
||||
## [4.1.0](https://github.com/expo/expo-github-action/compare/4.0.1...4.1.0) (2019-10-30)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
* use cmd suffix when authenticating on windows ([831bcb1](https://github.com/expo/expo-github-action/commit/831bcb1))
|
||||
|
||||
### Documentation changes
|
||||
|
||||
* remove beta warning just before general availability ([68a2de0](https://github.com/expo/expo-github-action/commit/68a2de0))
|
||||
|
||||
### Other chores
|
||||
|
||||
* update all dependencies to latest version ([16d4b15](https://github.com/expo/expo-github-action/commit/16d4b15))
|
||||
* enable workflow for pull requests ([8ff07e0](https://github.com/expo/expo-github-action/commit/8ff07e0))
|
||||
|
||||
|
||||
## [4.0.0](https://github.com/expo/expo-github-action/compare/3.0.0...4.0.0) (2019-09-29)
|
||||
|
||||
### New features
|
||||
|
||||
* add github workflow for ci ([929a76c](https://github.com/expo/expo-github-action/commit/929a76c))
|
||||
* add new expo action cli install concept ([98b1bea](https://github.com/expo/expo-github-action/commit/98b1bea))
|
||||
* use new action metadata format ([81344e4](https://github.com/expo/expo-github-action/commit/81344e4))
|
||||
|
||||
### Bug fixes
|
||||
|
||||
* add build and node node modules before commit ([00692c4](https://github.com/expo/expo-github-action/commit/00692c4))
|
||||
* add build and node node modules in husky hook ([b2929e3](https://github.com/expo/expo-github-action/commit/b2929e3))
|
||||
|
||||
### Code refactors
|
||||
|
||||
* remove travis config and base images ([e72ddd8](https://github.com/expo/expo-github-action/commit/e72ddd8))
|
||||
* move entry point to expo as proxy ([caf499b](https://github.com/expo/expo-github-action/commit/caf499b))
|
||||
* update proxy for non-interactive mode and help links ([5cfaee2](https://github.com/expo/expo-github-action/commit/5cfaee2))
|
||||
|
||||
### Documentation changes
|
||||
|
||||
* update documentation for the new action ([38e963b](https://github.com/expo/expo-github-action/commit/38e963b))
|
||||
* simplify and link the environment variables info ([26c734a](https://github.com/expo/expo-github-action/commit/26c734a))
|
||||
* replace aliased email with normal email ([f3bc71a](https://github.com/expo/expo-github-action/commit/f3bc71a))
|
||||
* write about entry point proxy and restructure for easy access ([4766fa8](https://github.com/expo/expo-github-action/commit/4766fa8))
|
||||
* update license dates ([89005bc](https://github.com/expo/expo-github-action/commit/89005bc))
|
||||
|
||||
### Other chores
|
||||
|
||||
* add linter and fix all files ([04cd479](https://github.com/expo/expo-github-action/commit/04cd479))
|
||||
* add husky for repository deployments ([cec6e50](https://github.com/expo/expo-github-action/commit/cec6e50))
|
||||
* add all missing tests ([22df52e](https://github.com/expo/expo-github-action/commit/22df52e))
|
||||
|
||||
|
||||
## [3.0.0](https://github.com/expo/expo-github-action/compare/2.3.2...3.0.0) (2019-07-23)
|
||||
|
||||
## Code refactors
|
||||
|
||||
* run travis in parallel for expo cli v2 and v3 ([882d5f9](https://github.com/expo/expo-github-action/commit/882d5f9))
|
||||
* add latest expo-cli v3 but keep v2 images updated ([cd33736](https://github.com/expo/expo-github-action/commit/cd33736))
|
||||
|
||||
|
||||
## [2.3.2](https://github.com/expo/expo-github-action/compare/2.3.1...2.3.2) (2019-05-09)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
* use yarn to install expo cli globally ([9fd3635](https://github.com/expo/expo-github-action/commit/9fd3635))
|
||||
|
||||
|
||||
## [2.3.1](https://github.com/expo/expo-github-action/compare/2.3.0...2.3.1) (2019-04-17)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
-14
@@ -1,14 +0,0 @@
|
||||
FROM bycedric/expo-cli:2
|
||||
|
||||
LABEL com.github.actions.name="Expo CLI"
|
||||
LABEL com.github.actions.description="Use any Expo CLI command in your GitHub Actions workflow."
|
||||
LABEL com.github.actions.icon="terminal"
|
||||
LABEL com.github.actions.color="gray-dark"
|
||||
|
||||
COPY entrypoint.sh LICENSE.md README.md /
|
||||
|
||||
# increase node's default memory limit to 4gb
|
||||
# see: https://github.com/expo/expo-github-action/#overwriting-node_options
|
||||
ENV NODE_OPTIONS="--max_old_space_size=4096"
|
||||
|
||||
entrypoint ["/entrypoint.sh"]
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
# The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2019 Cedric van Putten <me@bycedric.com>
|
||||
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,166 +1,294 @@
|
||||
# Expo for GitHub Actions
|
||||
|
||||
> GitHub Actions is still in beta, use it at your own risk.
|
||||
|
||||
Publish, build or manage your [Expo][link-expo] Project with GitHub Actions!
|
||||
This repository contains a prebuilt base image with GitHub Actions implementations.
|
||||
You can also use [the base image](base) in other Docker-based environments.
|
||||
<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 CLI action, you have full access to the original [Expo CLI][link-expo-cli].
|
||||
That means you can perform any command like login, publish and build.
|
||||
Also, this action will authenticate automatically when both `EXPO_CLI_USERNAME` and `EXPO_CLI_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.
|
||||
|
||||
> You don't necessarily need this action to use Expo.
|
||||
> You can also add `expo-cli` as a dependency to your project and use the official [NPM action][link-actions-npm] for example.
|
||||
> However, when you do that you need to manage authentication yourself.
|
||||
## Configuration options
|
||||
|
||||
### Why use a base-image?
|
||||
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.
|
||||
|
||||
Every GitHub action will start from scratch using the dockerfile as the starting point.
|
||||
If you define `expo-cli` in this dockerfile, it will install it every time you run an action.
|
||||
By using [a prebuilt image](base), it basically "skips" the process of downloading the full CLI over and over again.
|
||||
This makes the Expo actions overall faster.
|
||||
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).
|
||||
|
||||
### Used secrets
|
||||
> Never hardcode `expo-token` or `expo-password` in your workflow, use [secrets][link-actions-secrets] to store them.
|
||||
|
||||
To authenticate with your Expo account, use the variables listed below.
|
||||
In the Expo action you can define `secrets = ["EXPO_CLI_USERNAME", "EXPO_CLI_PASSWORD"]` to have them available.
|
||||
> It's also recommended to set the `expo-version` to avoid breaking changes when a new major version is released.
|
||||
|
||||
variable | description
|
||||
--- | ---
|
||||
`EXPO_CLI_USERNAME` | The email address or username of your Expo account.
|
||||
`EXPO_CLI_PASSWORD` | The password of your Expo account, [automatically picked up by the cli][link-expo-cli-password].
|
||||
> `expo-token` is available from Expo CLI `3.25.0`.
|
||||
|
||||
> Some Expo commands don't require authentication.
|
||||
> Simply omit the `secrets = [...]` if you don't need it.
|
||||
|
||||
### Some caveats
|
||||
|
||||
#### Overwriting `NODE_OPTIONS`
|
||||
|
||||
By default, Node has a "limited" memory limit.
|
||||
To fully use the available memory in GitHub Actions, the `NODE_OPTIONS` variable is set to `--max_old_space_size=4096`.
|
||||
If you need to overwrite this variable, make sure you add this value too or risk Node running out of memory.
|
||||
See [issue #12][link-issue-memory] for more info.
|
||||
|
||||
## 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](#publish-on-any-push)
|
||||
2. [Publish on a specific branch](#publish-on-a-specific-branch)
|
||||
3. [Test and build web every day at 08:00](#test-and-build-web-every-day-at-0800)
|
||||
1. [Publish on any push to master](#publish-on-any-push-to-master)
|
||||
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)
|
||||
6. [Authenticate using an Expo token](#authenticate-using-an-expo-token)
|
||||
|
||||
### Publish on any push
|
||||
### Publish on any push to master
|
||||
|
||||
Below you can see the example configuration to publish whenever the repository is updated.
|
||||
The workflow listens to the `push` event and resolves directly to the `publish` action.
|
||||
Before publishing your app, it installs your project's dependencies using the [NPM action][link-actions-npm].
|
||||
Below you can see the example configuration to publish whenever the master 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`.
|
||||
|
||||
```hcl
|
||||
workflow "Install and Publish" {
|
||||
on = "push"
|
||||
resolves = ["Publish"]
|
||||
}
|
||||
|
||||
action "Install" {
|
||||
uses = "actions/npm@master"
|
||||
args = "install"
|
||||
}
|
||||
|
||||
action "Publish" {
|
||||
needs = "Install"
|
||||
uses = "expo/[email protected]"
|
||||
args = "publish"
|
||||
secrets = ["EXPO_CLI_USERNAME", "EXPO_CLI_PASSWORD"]
|
||||
}
|
||||
```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-username: ${{ secrets.EXPO_CLI_USERNAME }}
|
||||
expo-password: ${{ secrets.EXPO_CLI_PASSWORD }}
|
||||
- run: yarn install
|
||||
- run: expo publish
|
||||
```
|
||||
|
||||
### Publish on a specific branch
|
||||
### Cache Expo CLI for other jobs
|
||||
|
||||
This workflow is similar to the [publish on any push](#publish-on-any-push) configuration.
|
||||
It will install and test the code using the [NPM action][link-actions-npm] on every push.
|
||||
But instead of publishing on any push too, it will publish on the `master` branch only.
|
||||
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 previously installed Expo CLI.
|
||||
It skips the installation part and extracts the files directly, boosting the performance of your workflow.
|
||||
|
||||
```hcl
|
||||
workflow "Install and Publish" {
|
||||
on = "push"
|
||||
resolves = ["Publish"]
|
||||
}
|
||||
> You can [read more about the cache here](#using-the-built-in-cache)
|
||||
|
||||
action "Install" {
|
||||
uses = "actions/npm@master"
|
||||
args = "install"
|
||||
}
|
||||
```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-username: ${{ secrets.EXPO_CLI_USERNAME }}
|
||||
expo-password: ${{ secrets.EXPO_CLI_PASSWORD }}
|
||||
expo-cache: true
|
||||
- run: yarn install
|
||||
- run: expo publish
|
||||
```
|
||||
|
||||
action "Test" {
|
||||
needs = "Install"
|
||||
uses = "actions/npm@master"
|
||||
args = "test"
|
||||
}
|
||||
### Test PRs and publish a review version
|
||||
|
||||
action "Filter branch" {
|
||||
needs = "Test"
|
||||
uses = "actions/bin/filter@master"
|
||||
args = "branch master"
|
||||
}
|
||||
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 [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.
|
||||
|
||||
action "Publish" {
|
||||
needs = "Filter branch"
|
||||
uses = "expo/[email protected]"
|
||||
args = "publish"
|
||||
secrets = ["EXPO_CLI_USERNAME", "EXPO_CLI_PASSWORD"]
|
||||
}
|
||||
```yml
|
||||
name: Expo Review
|
||||
on: [pull_request]
|
||||
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-username: ${{ secrets.EXPO_CLI_USERNAME }}
|
||||
expo-password: ${{ secrets.EXPO_CLI_PASSWORD }}
|
||||
- run: yarn install
|
||||
- run: expo publish --release-channel=pr-${{ github.event.number }}
|
||||
- uses: unsplash/comment-on-pr@master
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
msg: App is ready for review, you can [see it here](https://expo.io/@bycedric/use-expo?release-channel=pr-${{ github.event.number }}).
|
||||
```
|
||||
|
||||
### Test PRs on multiple nodes and systems
|
||||
|
||||
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.
|
||||
|
||||
> If you don't need automatic authentication, you can omit the `expo-username` and `expo-password` variables.
|
||||
|
||||
```yml
|
||||
name: Expo CI
|
||||
on: [pull_request]
|
||||
jobs:
|
||||
ci:
|
||||
name: Continuous Integration
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, macOS-latest, windows-latest]
|
||||
node: [10, 12, 13]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node }}
|
||||
- uses: expo/expo-github-action@v5
|
||||
with:
|
||||
expo-version: 3.x
|
||||
- run: yarn install
|
||||
- run: yarn test
|
||||
- run: expo doctor
|
||||
```
|
||||
|
||||
### Test and build web every day at 08:00
|
||||
|
||||
The most significant change here is that we've changed the workflow trigger.
|
||||
Instead of listening to push events, it's scheduled to run every day at 08:00.
|
||||
You can also schedule jobs by using the cron syntax.
|
||||
It can help to minimize the number of updates your users have to install.
|
||||
|
||||
> For web builds, you don't need to be authenticated.
|
||||
> That's why `secrets = [...]` is omitted here.
|
||||
|
||||
```hcl
|
||||
workflow "Install, Test and Build for Web" {
|
||||
on = "schedule(0 8 * * *)"
|
||||
resolves = ["Build"]
|
||||
}
|
||||
|
||||
action "Install" {
|
||||
uses = "actions/npm@master"
|
||||
args = "install"
|
||||
}
|
||||
|
||||
action "Test" {
|
||||
needs = "Install"
|
||||
uses = "actions/npm@master"
|
||||
args = "test"
|
||||
}
|
||||
|
||||
action "Build" {
|
||||
needs = "Test"
|
||||
uses = "expo/[email protected]"
|
||||
args = "build:web"
|
||||
}
|
||||
```yml
|
||||
name: Expo Daily CI
|
||||
on:
|
||||
schedule:
|
||||
- cron: 0 8 * * *
|
||||
jobs:
|
||||
ci:
|
||||
name: Daily Continuous Integration
|
||||
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
|
||||
- run: yarn install
|
||||
- run: yarn test
|
||||
- run: expo build:web
|
||||
```
|
||||
|
||||
## License
|
||||
### Authenticate using an Expo token
|
||||
|
||||
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
|
||||
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
|
||||
```
|
||||
|
||||
<p align="center">
|
||||
with :heart: <a href="https://bycedric.com" target="_blank">byCedric</a>
|
||||
</p>
|
||||
## Things to know
|
||||
|
||||
[link-actions]: https://developer.github.com/actions/
|
||||
[link-actions-npm]: https://github.com/actions/npm
|
||||
[link-expo]: https://expo.io
|
||||
[link-expo-cli]: https://docs.expo.io/versions/latest/workflow/expo-cli
|
||||
[link-expo-cli-password]: https://github.com/expo/expo-cli/blob/8ea616d8848a123270b97e226e33dcb3dde49653/packages/expo-cli/src/accounts.js#L94
|
||||
[link-issue-memory]: https://github.com/expo/expo-github-action/issues/12
|
||||
### Automatic Expo login
|
||||
|
||||
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 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
|
||||
|
||||
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`.
|
||||
|
||||
<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-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/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/
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
---
|
||||
name: Expo GitHub Action
|
||||
author: Cedric van Putten <[email protected]>
|
||||
description: Expo CLI in your GitHub Actions workflow.
|
||||
branding:
|
||||
icon: terminal
|
||||
color: gray-dark
|
||||
runs:
|
||||
using: node12
|
||||
main: build/index.js
|
||||
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:
|
||||
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
|
||||
expo-cache:
|
||||
description: If Expo should be stored in the GitHub Actions cache (can be true or false)
|
||||
default: false
|
||||
expo-cache-key:
|
||||
description: A custom remote cache key to use (best to let GitHub Actions handle it)
|
||||
@@ -1,14 +0,0 @@
|
||||
FROM node:10
|
||||
|
||||
LABEL name="Expo for Docker"
|
||||
LABEL repository="https://github.com/expo/expo-github-action"
|
||||
LABEL homepage="https://github.com/expo/expo-github-action/blob/master/base"
|
||||
LABEL maintainer="Cedric van Putten <[email protected]>"
|
||||
|
||||
RUN npm install --global expo-cli@2 \
|
||||
&& npm cache rm --force \
|
||||
&& rm -rf ~/.npm
|
||||
|
||||
COPY entrypoint.sh LICENSE.md README.md /
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
@@ -1,22 +0,0 @@
|
||||
# The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2019 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
|
||||
> of this software and associated documentation files (the "Software"), to deal
|
||||
> in the Software without restriction, including without limitation the rights
|
||||
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
> copies of the Software, and to permit persons to whom the Software is
|
||||
> furnished to do so, subject to the following conditions:
|
||||
>
|
||||
> The above copyright notice and this permission notice shall be included in
|
||||
> all copies or substantial portions of the Software.
|
||||
>
|
||||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
> THE SOFTWARE.
|
||||
@@ -1,40 +0,0 @@
|
||||
# Expo for Docker
|
||||
|
||||
[](https://travis-ci.com/expo/expo-github-action)
|
||||
|
||||
A prebuilt docker image to use the [Expo CLI][link-expo-cli] on Docker-based environments.
|
||||
This image contains all necessary libraries to perform all commands of the CLI.
|
||||
To make sure this image stays up to date, Travis CI is scheduled to run weekly builds.
|
||||
|
||||
- Based on `node:10` image
|
||||
- Contains globally installed `expo-cli@2`
|
||||
|
||||
## Usage
|
||||
|
||||
The entry point of this image forwards to the Expo CLI itself.
|
||||
With this entry point, you can provide any command directly to Docker.
|
||||
When nothing is provided, it will output the help information provided by the CLI.
|
||||
|
||||
> The entry point uses `sh -c` to invoke Expo, making environment variables available to that command.
|
||||
|
||||
```bash
|
||||
$ docker run --rm bycedric/expo-cli
|
||||
$ docker run --rm bycedric/expo-cli pubish
|
||||
$ docker run --rm -ti bycedric/expo-cli login
|
||||
$ docker run --rm -ti --entrypoint sh bycedric/expo-cli
|
||||
```
|
||||
|
||||
> This image is intended to use on Docker-based CI environments, see [the Expo CI guide][link-expo-cicd] to get started.
|
||||
|
||||
## 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>
|
||||
|
||||
[link-expo-cli]: https://docs.expo.io/versions/latest/workflow/expo-cli
|
||||
[link-expo-cicd]: https://docs.expo.io/versions/latest/guides/setting-up-continuous-integration
|
||||
@@ -1,4 +0,0 @@
|
||||
#!/bin/sh -l
|
||||
|
||||
set -e
|
||||
sh -c "expo $*"
|
||||
Executable
+24
@@ -0,0 +1,24 @@
|
||||
if (module !== require.main) {
|
||||
throw new Error("This file should not be loaded with require()")
|
||||
}
|
||||
|
||||
if (!process.getuid || !process.getgid) {
|
||||
throw new Error("this file should not be called without uid/gid support")
|
||||
}
|
||||
|
||||
var argv = process.argv.slice(2)
|
||||
, user = argv[0] || process.getuid()
|
||||
, group = argv[1] || process.getgid()
|
||||
|
||||
if (!isNaN(user)) user = +user
|
||||
if (!isNaN(group)) group = +group
|
||||
|
||||
console.error([user, group])
|
||||
|
||||
try {
|
||||
process.setgid(group)
|
||||
process.setuid(user)
|
||||
console.log(JSON.stringify({uid:+process.getuid(), gid:+process.getgid()}))
|
||||
} catch (ex) {
|
||||
console.log(JSON.stringify({error:ex.message,errno:ex.errno}))
|
||||
}
|
||||
+72765
File diff suppressed because it is too large.
Load diff
@@ -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)
|
||||
@@ -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"
|
||||
}
|
||||
@@ -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
|
||||
@@ -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"
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
#!/bin/sh -l
|
||||
|
||||
set -e
|
||||
|
||||
if [ -n "$EXPO_CLI_USERNAME" ] && [ -n "$EXPO_CLI_PASSWORD" ]; then
|
||||
expo login --username $EXPO_CLI_USERNAME
|
||||
else
|
||||
echo 'Skipping Expo login, username and/or password not defined...'
|
||||
fi
|
||||
|
||||
sh -c "expo $*"
|
||||
@@ -0,0 +1,11 @@
|
||||
module.exports = {
|
||||
verbose: true,
|
||||
clearMocks: true,
|
||||
moduleFileExtensions: ['js', 'ts'],
|
||||
testEnvironment: 'node',
|
||||
testMatch: ['**/*.test.ts'],
|
||||
testRunner: 'jest-circus/runner',
|
||||
transform: {
|
||||
'^.+\\.ts$': 'ts-jest'
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,51 @@
|
||||
{
|
||||
"private": true,
|
||||
"name": "expo-github-action",
|
||||
"version": "5.3.0",
|
||||
"description": "Expo CLI in your GitHub Actions workflow",
|
||||
"main": "build/index.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/expo/expo-github-action.git"
|
||||
},
|
||||
"author": "Cedric van Putten <[email protected]>",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/expo/expo-github-action/issues"
|
||||
},
|
||||
"homepage": "https://github.com/expo/expo-github-action#readme",
|
||||
"scripts": {
|
||||
"test": "jest",
|
||||
"lint": "tsc --noEmit && eslint --ext ts ./src ./tests",
|
||||
"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/exec": "^1.0.4",
|
||||
"@actions/io": "^1.0.2",
|
||||
"@actions/tool-cache": "^1.5.5",
|
||||
"libnpm": "^3.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@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.1.0",
|
||||
"rimraf": "^3.0.2",
|
||||
"ts-jest": "^26.1.2",
|
||||
"typescript": "^3.9.6"
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "yarn build && git add build"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
import { restoreCache, saveCache } from '@actions/cache/lib';
|
||||
import * as toolCache from '@actions/tool-cache';
|
||||
import path from 'path';
|
||||
import os from 'os';
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store the root of `expo-cli` in the cache, for future reuse.
|
||||
* Note, this cache is **NOT** shared between jobs.
|
||||
*
|
||||
* @see https://github.com/actions/toolkit/issues/47
|
||||
*/
|
||||
export async function toLocalCache(root: string, version: string) {
|
||||
return toolCache.cacheDir(root, 'expo-cli', 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) {
|
||||
// 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);
|
||||
|
||||
if (hit) {
|
||||
return target;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
await saveCache(source, cacheKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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}`;
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
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 authWithCredentials(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,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 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...');
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import * as core from '@actions/core';
|
||||
import { run } from './run';
|
||||
|
||||
run().catch(core.setFailed);
|
||||
@@ -0,0 +1,65 @@
|
||||
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');
|
||||
|
||||
type InstallConfig = {
|
||||
version: string;
|
||||
packager: string;
|
||||
cache?: boolean;
|
||||
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);
|
||||
|
||||
if (!root && config.cache) {
|
||||
root = await fromRemoteCache(exact, config.packager, config.cacheKey);
|
||||
} else {
|
||||
core.info('Skipping remote cache, not enabled...');
|
||||
}
|
||||
|
||||
if (!root) {
|
||||
root = await fromPackager(exact, config.packager);
|
||||
root = await toLocalCache(root, exact);
|
||||
|
||||
if (config.cache) {
|
||||
await toRemoteCache(root, exact, config.packager, config.cacheKey);
|
||||
}
|
||||
}
|
||||
|
||||
return path.join(root, 'node_modules', '.bin');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
const root = process.env['RUNNER_TEMP'] || '';
|
||||
const tool = await io.which(packager);
|
||||
|
||||
await io.mkdirP(root);
|
||||
await cli.exec(tool, ['add', `expo-cli@${version}`], { cwd: root });
|
||||
|
||||
return root;
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
import { addPath, getInput } from '@actions/core';
|
||||
import { authenticate } from './expo';
|
||||
import { install } from './install';
|
||||
import { patchWatchers } from './system';
|
||||
|
||||
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,
|
||||
});
|
||||
|
||||
addPath(path);
|
||||
|
||||
await authenticate({
|
||||
token: getInput('expo-token') || undefined,
|
||||
username: getInput('expo-username') || undefined,
|
||||
password: getInput('expo-password') || undefined,
|
||||
});
|
||||
|
||||
const shouldPatchWatchers = getInput('expo-patch-watchers') || 'true';
|
||||
|
||||
if (shouldPatchWatchers !== 'false') {
|
||||
await patchWatchers();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
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');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
import os from 'os';
|
||||
import { join } from 'path';
|
||||
import * as remoteCache from '@actions/cache/lib';
|
||||
import * as toolCache from '@actions/tool-cache';
|
||||
import * as cache from '../src/cache';
|
||||
import * as utils from './utils';
|
||||
|
||||
describe('fromLocalCache', () => {
|
||||
it('fetches the version specific cache', async () => {
|
||||
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');
|
||||
expect(result).toBe(path);
|
||||
expect(find).toBeCalledWith('expo-cli', '3.20.1');
|
||||
});
|
||||
});
|
||||
|
||||
describe('toLocalCache', () => {
|
||||
it('stores the version specific cache', async () => {
|
||||
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);
|
||||
expect(cacheDir).toBeCalledWith(root, 'expo-cli', '3.20.1');
|
||||
});
|
||||
});
|
||||
|
||||
describe('fromRemoteCache', () => {
|
||||
let spy: { [key: string]: jest.SpyInstance } = {};
|
||||
|
||||
beforeEach(() => {
|
||||
spy = {
|
||||
restore: jest.spyOn(remoteCache, 'restoreCache').mockImplementation(),
|
||||
};
|
||||
});
|
||||
|
||||
beforeAll(() => {
|
||||
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(
|
||||
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(
|
||||
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(
|
||||
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);
|
||||
});
|
||||
});
|
||||
|
||||
describe('toRemoteCache', () => {
|
||||
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(join('local', 'path'), '3.20.1', 'npm')).toBeUndefined();
|
||||
expect(remoteCache.saveCache).toBeCalledWith(
|
||||
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(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(join('local', 'path'), '3.20.1', 'yarn')).rejects.toBe(error);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,148 @@
|
||||
import * as core from '@actions/core';
|
||||
import * as cli from '@actions/exec';
|
||||
import * as expo from '../src/expo';
|
||||
import * as utils from './utils';
|
||||
|
||||
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.authWithCredentials();
|
||||
expect(spy.exec).not.toBeCalled();
|
||||
expect(spy.info).toBeCalledWith(expect.stringContaining('Skipping authentication'));
|
||||
});
|
||||
|
||||
it('skips authentication without password', async () => {
|
||||
await expo.authWithCredentials(USER);
|
||||
expect(spy.exec).not.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.authWithCredentials(USER, PASS);
|
||||
expect(spy.exec).toBeCalled();
|
||||
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: PASS,
|
||||
},
|
||||
});
|
||||
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(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.authWithCredentials(USER, PASS);
|
||||
expect(spy.exec).toBeCalled();
|
||||
expect(spy.exec.mock.calls[0][0]).toBe('expo.cmd');
|
||||
utils.restorePlatform();
|
||||
});
|
||||
});
|
||||
|
||||
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.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();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,91 @@
|
||||
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(),
|
||||
toLocalCache: jest.fn(),
|
||||
toRemoteCache: jest.fn(),
|
||||
};
|
||||
|
||||
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(join('cache', 'path'));
|
||||
const expoPath = await install.install({ 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', join('temp', 'path'));
|
||||
cache.fromLocalCache.mockResolvedValue(undefined);
|
||||
cache.toLocalCache.mockResolvedValue(join('cache', 'path'));
|
||||
const expoPath = await install.install({ version: '3.0.10', packager: 'npm' });
|
||||
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(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(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', join('temp', 'path'));
|
||||
cache.fromLocalCache.mockResolvedValue(undefined);
|
||||
cache.fromRemoteCache.mockResolvedValue(undefined);
|
||||
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(join('cache', 'path', 'node_modules', '.bin'));
|
||||
expect(cache.toRemoteCache).toBeCalledWith(join('cache', 'path'), '3.20.1', 'npm', undefined);
|
||||
utils.restoreEnv();
|
||||
});
|
||||
});
|
||||
|
||||
describe('fromPackager', () => {
|
||||
it('resolves tool path', async () => {
|
||||
await install.fromPackager('3.0.10', 'npm');
|
||||
expect(io.which).toBeCalledWith('npm');
|
||||
});
|
||||
|
||||
it('creates temporary folder', async () => {
|
||||
utils.setEnv('RUNNER_TEMP', join('temp', 'path'));
|
||||
await install.fromPackager('latest', 'yarn');
|
||||
expect(io.mkdirP).toBeCalledWith(join('temp', 'path'));
|
||||
utils.restoreEnv();
|
||||
});
|
||||
|
||||
it('installs expo with tool', async () => {
|
||||
utils.setEnv('RUNNER_TEMP', join('temp', 'path'));
|
||||
io.which.mockResolvedValue('npm');
|
||||
const expoPath = await install.fromPackager('beta', '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: join('temp', 'path') });
|
||||
utils.restoreEnv();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,102 @@
|
||||
const core = { addPath: jest.fn(), getInput: jest.fn() };
|
||||
const exec = { exec: jest.fn() };
|
||||
const expo = { authenticate: jest.fn() };
|
||||
const install = { install: jest.fn() };
|
||||
const system = { patchWatchers: jest.fn() };
|
||||
|
||||
jest.mock('@actions/core', () => core);
|
||||
jest.mock('@actions/exec', () => exec);
|
||||
jest.mock('../src/expo', () => expo);
|
||||
jest.mock('../src/install', () => install);
|
||||
jest.mock('../src/system', () => system);
|
||||
|
||||
import { run } from '../src/run';
|
||||
|
||||
interface MockInputProps {
|
||||
version?: string;
|
||||
packager?: string;
|
||||
token?: 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-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 '';
|
||||
}
|
||||
};
|
||||
|
||||
// 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();
|
||||
});
|
||||
|
||||
it('patches the system when not set', async () => {
|
||||
mockInput({ patchWatchers: '' });
|
||||
await run();
|
||||
expect(system.patchWatchers).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('skips the system patch when set to false', async () => {
|
||||
mockInput({ patchWatchers: 'false' });
|
||||
await run();
|
||||
expect(system.patchWatchers).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('authenticates with provided credentials', async () => {
|
||||
mockInput({ username: 'bycedric', password: 'mypassword', patchWatchers: 'false' });
|
||||
await run();
|
||||
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' });
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,67 @@
|
||||
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', () => {
|
||||
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();
|
||||
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();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,34 @@
|
||||
// keep track of the original one to revert the platform
|
||||
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) {
|
||||
Object.defineProperty(process, 'platform', { value: platform });
|
||||
}
|
||||
|
||||
/**
|
||||
* Revert the platform to the original one.
|
||||
*/
|
||||
export function restorePlatform() {
|
||||
setPlatform(originalPlatform);
|
||||
}
|
||||
|
||||
// keep track of the original environment variables
|
||||
const originalEnv = { ...process.env };
|
||||
|
||||
/**
|
||||
* Change the environment variable for testing purposes.
|
||||
*/
|
||||
export function setEnv(name: string, value: string) {
|
||||
process.env[name] = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Revert the environment variable changes.
|
||||
*/
|
||||
export function restoreEnv() {
|
||||
process.env = originalEnv;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es6",
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"outDir": "./build",
|
||||
"rootDir": "./src",
|
||||
"strict": true,
|
||||
"noImplicitAny": false,
|
||||
"esModuleInterop": true
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"tests/**"
|
||||
]
|
||||
}
|
||||
Reference in new issue
Block a user