mirror of
https://github.com/expo/expo-github-action.git
synced 2026-11-15 17:32:45 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d4dc05e178 | ||
|
|
04e3b32e94 | ||
|
|
a11a47a3e8 | ||
|
|
79ebfbc3b8 | ||
|
|
6b8c488fd6 | ||
|
|
f13b0ea032 | ||
|
|
6354b0a047 | ||
|
|
da4e75428b | ||
|
|
6bc0bedbc7 | ||
|
|
9c0e696251 |
No files matched your search
@@ -0,0 +1,51 @@
|
||||
---
|
||||
name: Release
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
release:
|
||||
description: 'type "release" to confirm creating a new release (main branch only)'
|
||||
required: false
|
||||
jobs:
|
||||
release:
|
||||
name: Release version
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Setup repo
|
||||
uses: actions/checkout@v2
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 14.x
|
||||
- name: Find cache
|
||||
id: yarn-cache-path
|
||||
run: echo "::set-output name=dir::$(yarn cache dir)"
|
||||
- name: Restore cache
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ steps.yarn-cache-path.outputs.dir }}
|
||||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-yarn-
|
||||
- name: Install dependencies
|
||||
run: yarn install --frozen-lockfile --check-files
|
||||
- name: Lint package
|
||||
run: yarn lint
|
||||
- name: Test package
|
||||
run: yarn test
|
||||
- name: Build clean
|
||||
run: yarn clean
|
||||
- name: Build package
|
||||
run: yarn build
|
||||
- name: Build up-to-date
|
||||
run: git diff --stat --exit-code build
|
||||
- name: Test-run release
|
||||
if: success() && github.event.inputs.release != 'release'
|
||||
run: yarn semantic-release --dry-run
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Create release
|
||||
if: success() && github.event.inputs.release == 'release' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
|
||||
run: yarn semantic-release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -0,0 +1 @@
|
||||
_
|
||||
Executable
+5
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
. "$(dirname "$0")/_/husky.sh"
|
||||
|
||||
yarn build
|
||||
git add build
|
||||
@@ -0,0 +1,38 @@
|
||||
const rules = [
|
||||
{ type: 'feat', release: 'minor', title: 'New features' },
|
||||
{ type: 'feature', release: 'minor', title: 'New features' },
|
||||
{ type: 'fix', release: 'patch', title: 'Bug fixes' },
|
||||
{ type: 'refactor', release: 'patch', title: 'Code changes' },
|
||||
{ type: 'chore', release: 'patch', title: 'Other chores' },
|
||||
{ type: 'docs', release: 'patch', title: 'Documentation changes' },
|
||||
];
|
||||
|
||||
// Simple mapping to order the commit groups
|
||||
const sortMap = Object.fromEntries(rules.map((rule, index) => [rule.title, index]));
|
||||
|
||||
module.exports = {
|
||||
branches: ['main', 'master'],
|
||||
tagFormat: '${version}',
|
||||
plugins: [
|
||||
['@semantic-release/commit-analyzer', {
|
||||
preset: 'conventionalcommits',
|
||||
releaseRules: rules.map(({ type, release }) => ({ type, release })),
|
||||
}],
|
||||
['@semantic-release/release-notes-generator', {
|
||||
preset: 'conventionalcommits',
|
||||
presetConfig: {
|
||||
types: rules.map(({ type, title }) => ({ type, section: title })),
|
||||
},
|
||||
writerOpts: {
|
||||
commitGroupsSort: (a, z) => sortMap[a.title] - sortMap[z.title],
|
||||
},
|
||||
}],
|
||||
'@semantic-release/changelog',
|
||||
['@semantic-release/npm', { npmPublish: false }],
|
||||
['@semantic-release/git', {
|
||||
message: 'chore: create new release ${nextRelease.version}\n\n${nextRelease.notes}',
|
||||
assets: ['package.json', 'CHANGELOG.md'],
|
||||
}],
|
||||
'@semantic-release/github',
|
||||
],
|
||||
};
|
||||
@@ -1,3 +1,34 @@
|
||||
## [5.5.0](https://github.com/expo/expo-github-action/compare/5.4.0...5.5.0) (2021-06-17)
|
||||
|
||||
|
||||
### New features
|
||||
|
||||
* switch to node 14 for the action itself ([f13b0ea](https://github.com/expo/expo-github-action/commit/f13b0ea032efcf2e6689743879af6b3e1c72201d))
|
||||
|
||||
|
||||
### Bug fixes
|
||||
|
||||
* add support for environments without remote cache ([#91](https://github.com/expo/expo-github-action/issues/91)) ([9c0e696](https://github.com/expo/expo-github-action/commit/9c0e6962510d4e08c6429cac42f624c563675ee1))
|
||||
|
||||
|
||||
### Code changes
|
||||
|
||||
* simplify typescript config with community config ([#94](https://github.com/expo/expo-github-action/issues/94)) ([da4e754](https://github.com/expo/expo-github-action/commit/da4e75428b7c5ffd16e8b2c698f590313c741621))
|
||||
* update all dependencies to latest versions ([#93](https://github.com/expo/expo-github-action/issues/93)) ([6bc0bed](https://github.com/expo/expo-github-action/commit/6bc0bedbc75bb0d6743e4accf032cd01348d6775))
|
||||
|
||||
|
||||
### Other chores
|
||||
|
||||
* add semantic release for easy versioning ([#95](https://github.com/expo/expo-github-action/issues/95)) ([6354b0a](https://github.com/expo/expo-github-action/commit/6354b0a0477a72375cee808d8a5b6006d6e86e77))
|
||||
* fix the allowed branches for semenatic release ([6b8c488](https://github.com/expo/expo-github-action/commit/6b8c488fd6239c9a76d7f95355a58bc8b2a20ac4))
|
||||
* mock the github actions warning to avoid leaking annotations ([#96](https://github.com/expo/expo-github-action/issues/96)) ([a11a47a](https://github.com/expo/expo-github-action/commit/a11a47a3e8735a206eed196499604322b0bdc877))
|
||||
* tweak the release workflow ([79ebfbc](https://github.com/expo/expo-github-action/commit/79ebfbc3b83497f443fd65eb5bd33484e5519f64))
|
||||
|
||||
|
||||
### Documentation changes
|
||||
|
||||
* add missing release step to contributing guide ([04e3b32](https://github.com/expo/expo-github-action/commit/04e3b32e94e3abe9cd65d37c57a0cead55186970))
|
||||
|
||||
## [5.4.0](https://github.com/expo/expo-github-action/compare/5.3.1...5.4.0) (2021-01-12)
|
||||
|
||||
### New features
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
# Contributing to Expo Github Action
|
||||
|
||||
## 📦 Download and Setup
|
||||
|
||||
1. [Fork](https://help.github.com/articles/fork-a-repo/) this repository to your own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) it to your local device. (`git remote add upstream [email protected]:expo/vscode-expo.git` 😉)
|
||||
2. Make sure you have the following packages globally installed on your system:
|
||||
- [node](https://nodejs.org/) (active Node LTS or higher is recommended)
|
||||
- [yarn](https://yarnpkg.com/)
|
||||
3. Install the Node packages (`yarn install`)
|
||||
|
||||
## 🏎️ Running a custom version
|
||||
|
||||
To try out your changed with Github Action, you have [to reference your fork and/or branch or commit reference](https://docs.github.com/en/actions/learn-github-actions/finding-and-customizing-actions#using-release-management-for-your-custom-actions) in the workflow you want to try. After that, you have two options:
|
||||
|
||||
1. Run the workflow in Github Actions itself by triggering your workflow.
|
||||
2. Run the workflow locally with [nektos/act](https://github.com/nektos/act).
|
||||
|
||||
## ✅ Testing
|
||||
|
||||
Testing is done using [Jest](https://jestjs.io/https://jestjs.io/). Run `yarn test` to run Jest.
|
||||
|
||||
In CI we are running tests on multiple Node versions using Windows, Linux, and MacOS. Make sure they are passing for your PR.
|
||||
|
||||
## 📝 Writing a Commit Message
|
||||
|
||||
> If this is your first time committing to a large public repo, you could look through this neat tutorial: ["How to Write a Git Commit Message"](https://chris.beams.io/posts/git-commit/)
|
||||
|
||||
Commit messages are formatted using the [Conventional Commits](https://www.conventionalcommits.org/) format. You can take a look at [`.releaserc.js`](./.releaserc.js) for the allowed commit types.
|
||||
|
||||
```
|
||||
docs: fix typo in xxx
|
||||
feature: add support for SDK 40
|
||||
chore: add test-case for custom completions
|
||||
fix: improve logging for errors
|
||||
refactor: update loading icon
|
||||
```
|
||||
|
||||
## 🔎 Before Submitting a PR
|
||||
|
||||
To get your PR merged as fast as possible, please make sure you have done the following:
|
||||
|
||||
- Run `yarn lint --fix` to fix the formatting of the code. Ensure that `yarn lint` succeeds without errors or warnings.
|
||||
- Run `yarn test` to make sure all normal use cases are passing.
|
||||
- Run `yarn build` to ensure the build is up-to-date and runs correctly and without errors or warnings.
|
||||
|
||||
## 🚀 Releasing a new version
|
||||
|
||||
To release a new version for Github Actions, we have to create a new release in Github. You can run the `Release` workflow to generate a new version, changelog, and Github release.
|
||||
|
||||
After the exact version tag is created, update the `v{major}` tag to the latest major version.
|
||||
+1
-1
@@ -6,7 +6,7 @@ branding:
|
||||
icon: terminal
|
||||
color: gray-dark
|
||||
runs:
|
||||
using: node12
|
||||
using: node14
|
||||
main: build/index.js
|
||||
inputs:
|
||||
expo-version:
|
||||
|
||||
+138155
-107981
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"
|
||||
}
|
||||
+26
-25
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"private": true,
|
||||
"name": "expo-github-action",
|
||||
"version": "5.3.0",
|
||||
"version": "5.5.0",
|
||||
"description": "Expo CLI in your GitHub Actions workflow",
|
||||
"main": "build/index.js",
|
||||
"repository": {
|
||||
@@ -18,36 +18,37 @@
|
||||
"test": "jest",
|
||||
"lint": "tsc --noEmit && eslint --ext ts ./src ./tests",
|
||||
"build": "ncc build src/index.ts --out build",
|
||||
"clean": "rimraf build"
|
||||
"clean": "rimraf build",
|
||||
"prepare": "husky install"
|
||||
},
|
||||
"dependencies": {
|
||||
"@actions/cache": "^1.0.4",
|
||||
"@actions/core": "^1.2.6",
|
||||
"@actions/exec": "^1.0.4",
|
||||
"@actions/io": "^1.0.2",
|
||||
"@actions/tool-cache": "^1.6.1",
|
||||
"@actions/cache": "^1.0.7",
|
||||
"@actions/core": "^1.4.0",
|
||||
"@actions/exec": "^1.1.0",
|
||||
"@actions/io": "^1.1.1",
|
||||
"@actions/tool-cache": "^1.7.1",
|
||||
"libnpm": "^3.0.1",
|
||||
"semver": "^7.3.4"
|
||||
"semver": "^7.3.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^26.0.16",
|
||||
"@types/node": "^14.14.10",
|
||||
"@types/semver": "^7.3.4",
|
||||
"@typescript-eslint/eslint-plugin": "^4.9.0",
|
||||
"@typescript-eslint/parser": "^4.9.0",
|
||||
"@semantic-release/changelog": "^5.0.1",
|
||||
"@semantic-release/git": "^9.0.0",
|
||||
"@tsconfig/node14": "^1.0.1",
|
||||
"@types/jest": "^26.0.23",
|
||||
"@types/node": "^14.17.3",
|
||||
"@types/semver": "^7.3.6",
|
||||
"@typescript-eslint/eslint-plugin": "^4.27.0",
|
||||
"@typescript-eslint/parser": "^4.27.0",
|
||||
"@zeit/ncc": "^0.22.3",
|
||||
"eslint": "^7.14.0",
|
||||
"eslint-plugin-jest": "^24.1.3",
|
||||
"husky": "^4.3.0",
|
||||
"jest": "^26.6.3",
|
||||
"jest-circus": "^26.6.3",
|
||||
"conventional-changelog-conventionalcommits": "^4.6.0",
|
||||
"eslint": "^7.28.0",
|
||||
"eslint-plugin-jest": "^24.3.6",
|
||||
"husky": "^6.0.0",
|
||||
"jest": "^27.0.4",
|
||||
"jest-circus": "^27.0.4",
|
||||
"rimraf": "^3.0.2",
|
||||
"ts-jest": "^26.4.4",
|
||||
"typescript": "^4.1.2"
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "yarn build && git add build"
|
||||
}
|
||||
"semantic-release": "^17.4.4",
|
||||
"ts-jest": "^27.0.3",
|
||||
"typescript": "^4.3.3"
|
||||
}
|
||||
}
|
||||
+33
-7
@@ -32,10 +32,17 @@ export async function fromRemoteCache(version: string, packager: string, customC
|
||||
// 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);
|
||||
|
||||
if (hit) {
|
||||
return target;
|
||||
try {
|
||||
// When running with nektos/act, or other custom environments, the cache might not be set up.
|
||||
const hit = await restoreCache([target], cacheKey);
|
||||
if (hit) {
|
||||
return target;
|
||||
}
|
||||
} catch (error) {
|
||||
if (!handleRemoteCacheError(error)) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,10 +56,7 @@ export async function toRemoteCache(source: string, version: string, packager: s
|
||||
try {
|
||||
await saveCache([source], cacheKey);
|
||||
} catch (error) {
|
||||
if (error instanceof ReserveCacheError) {
|
||||
core.info('Skipping remote cache storage, encountered error:');
|
||||
core.info(error.message);
|
||||
} else {
|
||||
if (!handleRemoteCacheError(error)) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -64,3 +68,25 @@ export async function toRemoteCache(source: string, version: string, packager: s
|
||||
function getRemoteKey(version: string, packager: string): string {
|
||||
return `expo-cli-${process.platform}-${os.arch()}-${packager}-${version}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle any incoming errors from cache methods.
|
||||
* This can include actual errors like `ReserveCacheErrors` or unavailability errors.
|
||||
* When the error is handled, it MUST provide feedback for the developer.
|
||||
*
|
||||
* @returns If the error was handled properly.
|
||||
*/
|
||||
function handleRemoteCacheError(error: Error): boolean {
|
||||
const isReserveCacheError = error instanceof ReserveCacheError;
|
||||
const isCacheUnavailable = error.message.toLowerCase().includes(
|
||||
'cache service url not found',
|
||||
);
|
||||
|
||||
if (isReserveCacheError || isCacheUnavailable) {
|
||||
core.warning('Skipping remote cache storage, encountered error:');
|
||||
core.warning(error.message);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import os from 'os';
|
||||
import { join } from 'path';
|
||||
import * as remoteCache from '@actions/cache';
|
||||
import * as core from '@actions/core';
|
||||
import * as toolCache from '@actions/tool-cache';
|
||||
|
||||
import * as cache from '../src/cache';
|
||||
@@ -34,6 +35,7 @@ describe('fromRemoteCache', () => {
|
||||
beforeEach(() => {
|
||||
spy = {
|
||||
restore: jest.spyOn(remoteCache, 'restoreCache').mockImplementation(),
|
||||
warning: jest.spyOn(core, 'warning').mockImplementation(),
|
||||
};
|
||||
});
|
||||
|
||||
@@ -44,6 +46,7 @@ describe('fromRemoteCache', () => {
|
||||
afterAll(() => {
|
||||
utils.restoreEnv();
|
||||
spy.restore.mockRestore();
|
||||
spy.warning.mockRestore();
|
||||
});
|
||||
|
||||
it('restores remote cache with default key', async () => {
|
||||
@@ -74,6 +77,14 @@ describe('fromRemoteCache', () => {
|
||||
spy.restore.mockRejectedValueOnce(error);
|
||||
await expect(cache.fromRemoteCache('3.20.1', 'yarn')).rejects.toBe(error);
|
||||
});
|
||||
|
||||
it('skips remote cache when unavailable', async () => {
|
||||
// see: https://github.com/actions/toolkit/blob/9167ce1f3a32ad495fc1dbcb574c03c0e013ae53/packages/cache/src/internal/cacheHttpClient.ts#L41
|
||||
const error = new Error('Cache Service Url not found, unable to restore cache.');
|
||||
spy.restore.mockRejectedValueOnce(error);
|
||||
await expect(cache.fromRemoteCache('3.20.1', 'yarn')).resolves.toBeUndefined();
|
||||
expect(spy.warning).toHaveBeenCalledWith(expect.stringContaining('Skipping remote cache'));
|
||||
});
|
||||
});
|
||||
|
||||
describe('toRemoteCache', () => {
|
||||
@@ -82,11 +93,13 @@ describe('toRemoteCache', () => {
|
||||
beforeEach(() => {
|
||||
spy = {
|
||||
save: jest.spyOn(remoteCache, 'saveCache').mockImplementation(),
|
||||
warning: jest.spyOn(core, 'warning').mockImplementation(),
|
||||
};
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
spy.save.mockRestore();
|
||||
spy.warning.mockRestore();
|
||||
});
|
||||
|
||||
it('saves remote cache with default key', async () => {
|
||||
@@ -107,4 +120,12 @@ describe('toRemoteCache', () => {
|
||||
spy.save.mockRejectedValueOnce(error);
|
||||
await expect(cache.toRemoteCache(join('local', 'path'), '3.20.1', 'yarn')).rejects.toBe(error);
|
||||
});
|
||||
|
||||
it('skips remote cache when unavailable', async () => {
|
||||
// see: https://github.com/actions/toolkit/blob/9167ce1f3a32ad495fc1dbcb574c03c0e013ae53/packages/cache/src/internal/cacheHttpClient.ts#L41
|
||||
const error = new Error('Cache Service Url not found, unable to restore cache.');
|
||||
spy.save.mockRejectedValueOnce(error);
|
||||
await expect(cache.toRemoteCache(join('local', 'path'), '3.20.1', 'yarn')).resolves.toBeUndefined();
|
||||
expect(spy.warning).toHaveBeenCalledWith(expect.stringContaining('Skipping remote cache'));
|
||||
});
|
||||
});
|
||||
+3
-8
@@ -1,17 +1,12 @@
|
||||
{
|
||||
"extends": "./node_modules/@tsconfig/node14/tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"target": "es6",
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"outDir": "./build",
|
||||
"rootDir": "./src",
|
||||
"strict": true,
|
||||
"noImplicitAny": false,
|
||||
"esModuleInterop": true
|
||||
"noImplicitAny": false
|
||||
},
|
||||
"exclude": [
|
||||
"build",
|
||||
"node_modules",
|
||||
"tests/**"
|
||||
]
|
||||
|
||||
Reference in new issue
Block a user