Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0985a44b32 | ||
|
|
f1d9b4b985 | ||
|
|
d134334a38 | ||
|
|
3b02a6fdc5 |
@@ -0,0 +1,27 @@
|
|||||||
|
import * as config from '../src/internal/shared/config'
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
jest.resetModules()
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('isGhes', () => {
|
||||||
|
it('should return false when the request domain is github.com', () => {
|
||||||
|
process.env.GITHUB_SERVER_URL = 'https://github.com'
|
||||||
|
expect(config.isGhes()).toBe(false)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should return false when the request domain ends with ghe.com', () => {
|
||||||
|
process.env.GITHUB_SERVER_URL = 'https://my.domain.ghe.com'
|
||||||
|
expect(config.isGhes()).toBe(false)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should return false when the request domain ends with ghe.localhost', () => {
|
||||||
|
process.env.GITHUB_SERVER_URL = 'https://my.domain.ghe.localhost'
|
||||||
|
expect(config.isGhes()).toBe(false)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should return false when the request domain is specific to an enterprise', () => {
|
||||||
|
process.env.GITHUB_SERVER_URL = 'https://my-enterprise.github.com'
|
||||||
|
expect(config.isGhes()).toBe(true)
|
||||||
|
})
|
||||||
|
})
|
||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@actions/artifact",
|
"name": "@actions/artifact",
|
||||||
"version": "2.0.1",
|
"version": "2.1.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@actions/artifact",
|
"name": "@actions/artifact",
|
||||||
"version": "2.0.1",
|
"version": "2.1.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.10.0",
|
"@actions/core": "^1.10.0",
|
||||||
|
|||||||
@@ -27,7 +27,13 @@ export function isGhes(): boolean {
|
|||||||
const ghUrl = new URL(
|
const ghUrl = new URL(
|
||||||
process.env['GITHUB_SERVER_URL'] || 'https://github.com'
|
process.env['GITHUB_SERVER_URL'] || 'https://github.com'
|
||||||
)
|
)
|
||||||
return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'
|
|
||||||
|
const hostname = ghUrl.hostname.trimEnd().toUpperCase()
|
||||||
|
const isGitHubHost = hostname === 'GITHUB.COM'
|
||||||
|
const isGheHost =
|
||||||
|
hostname.endsWith('.GHE.COM') || hostname.endsWith('.GHE.LOCALHOST')
|
||||||
|
|
||||||
|
return !isGitHubHost && !isGheHost
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getGitHubWorkspaceDir(): string {
|
export function getGitHubWorkspaceDir(): string {
|
||||||
|
|||||||
+24
@@ -2,6 +2,10 @@ import {promises as fs} from 'fs'
|
|||||||
import * as path from 'path'
|
import * as path from 'path'
|
||||||
import * as cacheUtils from '../src/internal/cacheUtils'
|
import * as cacheUtils from '../src/internal/cacheUtils'
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
jest.resetModules()
|
||||||
|
})
|
||||||
|
|
||||||
test('getArchiveFileSizeInBytes returns file size', () => {
|
test('getArchiveFileSizeInBytes returns file size', () => {
|
||||||
const filePath = path.join(__dirname, '__fixtures__', 'helloWorld.txt')
|
const filePath = path.join(__dirname, '__fixtures__', 'helloWorld.txt')
|
||||||
|
|
||||||
@@ -38,3 +42,23 @@ test('resolvePaths works on github workspace directory', async () => {
|
|||||||
const paths = await cacheUtils.resolvePaths([workspace])
|
const paths = await cacheUtils.resolvePaths([workspace])
|
||||||
expect(paths.length).toBeGreaterThan(0)
|
expect(paths.length).toBeGreaterThan(0)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('isGhes returns false for github.com', async () => {
|
||||||
|
process.env.GITHUB_SERVER_URL = 'https://github.com'
|
||||||
|
expect(cacheUtils.isGhes()).toBe(false)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('isGhes returns false for ghe.com', async () => {
|
||||||
|
process.env.GITHUB_SERVER_URL = 'https://somedomain.ghe.com'
|
||||||
|
expect(cacheUtils.isGhes()).toBe(false)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('isGhes returns true for enterprise URL', async () => {
|
||||||
|
process.env.GITHUB_SERVER_URL = 'https://my-enterprise.github.com'
|
||||||
|
expect(cacheUtils.isGhes()).toBe(true)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('isGhes returns false for ghe.localhost', () => {
|
||||||
|
process.env.GITHUB_SERVER_URL = 'https://my.domain.ghe.localhost'
|
||||||
|
expect(cacheUtils.isGhes()).toBe(false)
|
||||||
|
})
|
||||||
|
|||||||
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@actions/cache",
|
"name": "@actions/cache",
|
||||||
"version": "3.2.2",
|
"version": "3.2.3",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@actions/cache",
|
"name": "@actions/cache",
|
||||||
"version": "3.2.2",
|
"version": "3.2.3",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.10.0",
|
"@actions/core": "^1.10.0",
|
||||||
|
|||||||
+7
-1
@@ -135,5 +135,11 @@ export function isGhes(): boolean {
|
|||||||
const ghUrl = new URL(
|
const ghUrl = new URL(
|
||||||
process.env['GITHUB_SERVER_URL'] || 'https://github.com'
|
process.env['GITHUB_SERVER_URL'] || 'https://github.com'
|
||||||
)
|
)
|
||||||
return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'
|
|
||||||
|
const hostname = ghUrl.hostname.trimEnd().toUpperCase()
|
||||||
|
const isGitHubHost = hostname === 'GITHUB.COM'
|
||||||
|
const isGheHost =
|
||||||
|
hostname.endsWith('.GHE.COM') || hostname.endsWith('.GHE.LOCALHOST')
|
||||||
|
|
||||||
|
return !isGitHubHost && !isGheHost
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user