-
Notifications
You must be signed in to change notification settings - Fork 308
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
23 changed files
with
446 additions
and
326 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require('../../run')(module.filename) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require('../../run')(module.filename) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import {deleteFolder} from './helper' | ||
import {expect} from '@oclif/test' | ||
|
||
describe('helper', () => { | ||
it('should not do a recursive list', async () => { | ||
const list = await deleteFolder('dfc-data-production', 'media/salesforce-cli/oclif-testing/versions') | ||
expect(list).to.be.ok | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import * as qq from 'qqjs' | ||
import {expect} from '@oclif/test' | ||
import {gitSha} from '../../src/tarballs' | ||
import * as shelljs from 'shelljs' | ||
import * as S3 from 'aws-sdk/clients/s3' | ||
import aws from '../../src/aws' | ||
|
||
export const oclifTestingVersionsURI = 'media/salesforce-cli/oclif-testing/versions' | ||
export const oclifTestingChannelsURI = 'media/salesforce-cli/oclif-testing/channels' | ||
export const developerSalesforceCom = 'developer.salesforce.com' | ||
|
||
export const findDistFileSha = async (cwd: string, platform: string, filter: (f: string) => boolean): Promise<string[]> => { | ||
const distFiles = await qq.ls(`${cwd}/dist/${platform}/`) | ||
const pkg = distFiles.find(element => filter(element)) as string | ||
expect(pkg).to.be.ok | ||
return [pkg, await gitSha(process.cwd(), {short: true})] | ||
} | ||
|
||
export function gitShaSync(cwd: string, options: {short?: boolean} = {}): string { | ||
const args = options.short ? ['rev-parse', '--short', 'HEAD'] : ['rev-parse', 'HEAD'] | ||
const r = shelljs.exec(`git ${args.join(' ')}`, {cwd}) | ||
return r.stdout | ||
} | ||
|
||
export async function deleteFolder(bucket: string, folder: string): Promise<(string | undefined)[]> { | ||
const foundObjects = await aws.s3.listObjects({Bucket: bucket, Prefix: folder}) | ||
const foundKeys = foundObjects.Contents?.map(o => o.Key) | ||
if (foundKeys && foundKeys.length > 0) { | ||
const deleteObjectsRequest: S3.Types.DeleteObjectsRequest = { | ||
Bucket: bucket, | ||
Delete: {Objects: foundKeys!.map(k => ({Key: k} as S3.ObjectIdentifier))}, | ||
} | ||
const deletedObjects = await aws.s3.deleteObjects(deleteObjectsRequest) | ||
return deletedObjects?.Deleted ? deletedObjects.Deleted.map(o => o.Key) : [] | ||
} | ||
|
||
return [] | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import {expect, test} from '@oclif/test' | ||
import * as qq from 'qqjs' | ||
import {deleteFolder, developerSalesforceCom} from '../helpers/helper' | ||
import {gitSha} from '../../src/tarballs' | ||
|
||
const pjson = require('../../package.json') | ||
const pjsonPath = require.resolve('../../package.json') | ||
const originalVersion = pjson.version | ||
const target = [process.platform, process.arch].join('-') | ||
|
||
const onlyLinux = process.platform === 'linux' ? test : test.skip() | ||
const testRun = `test-${Math.random().toString().split('.')[1].slice(0, 4)}` | ||
|
||
// 2022-01 - this test requires linux with apt-ftparchive installed. Current CircleCi images do not have that util installed - skipping test | ||
describe.skip('publish:deb', () => { | ||
let bucket: string | ||
let basePrefix: string | ||
|
||
beforeEach(async () => { | ||
pjson.version = `${pjson.version}-${testRun}` | ||
bucket = pjson.oclif.update.s3.bucket | ||
basePrefix = pjson.oclif.update.s3.folder | ||
await deleteFolder(bucket, `${basePrefix}/versions/${pjson.version}/`) | ||
await qq.writeJSON(pjsonPath, pjson) | ||
const root = qq.join(__dirname, '../tmp/test/publish') | ||
await qq.emptyDir(root) | ||
qq.cd(root) | ||
}) | ||
afterEach(async () => { | ||
await deleteFolder(bucket, `${basePrefix}/versions/${pjson.version}/`) | ||
qq.cd([__dirname, '..']) | ||
pjson.version = originalVersion | ||
await qq.writeJSON(pjsonPath, pjson) | ||
}) | ||
|
||
onlyLinux | ||
.command(['pack:deb']) | ||
.command(['upload:deb']) | ||
.it('publishes valid releases', async () => { | ||
const sha = await gitSha(process.cwd(), {short: true}) | ||
qq.cd([__dirname, '..', '..']) | ||
await qq.x('cat test/release.key | apt-key add -') | ||
await qq.x(`echo "deb https://${developerSalesforceCom}/apt ./" > /etc/apt/sources.list.d/oclif-dev.list`) | ||
await qq.x('apt-get update') | ||
await qq.x('apt-get install -y oclif-dev') | ||
await qq.x('oclif --version') | ||
const stdout = await qq.x.stdout('oclif', ['--version']) | ||
expect(stdout).to.contain(`oclif/${pjson.version}.${sha} ${target} node-v${pjson.oclif.update.node.version}`) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import {test} from '@oclif/test' | ||
import * as qq from 'qqjs' | ||
import {findDistFileSha, developerSalesforceCom, deleteFolder} from '../helpers/helper' | ||
|
||
const pjson = require('../../package.json') | ||
const pjsonPath = require.resolve('../../package.json') | ||
const originalVersion = pjson.version | ||
|
||
const onlyMacos = process.platform === 'darwin' ? test : test.skip() | ||
const testRun = `test-${Math.random().toString().split('.')[1].slice(0, 4)}` | ||
|
||
describe('publish:macos', () => { | ||
const cwd = process.cwd() | ||
let pkg: string | ||
let sha: string | ||
let bucket: string | ||
let basePrefix: string | ||
beforeEach(async () => { | ||
pjson.version = `${pjson.version}-${testRun}` | ||
bucket = pjson.oclif.update.s3.bucket | ||
basePrefix = pjson.oclif.update.s3.folder | ||
await deleteFolder(bucket, `${basePrefix}/versions/${pjson.version}/`) | ||
await qq.writeJSON(pjsonPath, pjson) | ||
const root = qq.join(__dirname, '../tmp/test/publish') | ||
await qq.emptyDir(root) | ||
qq.cd(root) | ||
}) | ||
afterEach(async () => { | ||
await deleteFolder(bucket, `${basePrefix}/versions/${pjson.version}/`) | ||
qq.cd([__dirname, '..']) | ||
pjson.version = originalVersion | ||
await qq.writeJSON(pjsonPath, pjson) | ||
}) | ||
|
||
onlyMacos | ||
.command(['pack:macos']) | ||
.do(async () => { | ||
[pkg, sha] = await findDistFileSha(cwd, 'macos', f => f.endsWith('pkg')) | ||
}) | ||
.command(['upload:macos']) | ||
.it('publishes valid releases', async () => { | ||
await qq.download(`https://${developerSalesforceCom}/${basePrefix}/versions/${pjson.version}/${sha}/${pkg}`) | ||
}) | ||
}) |
File renamed without changes.
Oops, something went wrong.