test: use semanticrelease/npm-registry-docker Docker image for tests
				
					
				
			This commit is contained in:
		
							parent
							
								
									b9af5c42c9
								
							
						
					
					
						commit
						1d4f67e5e8
					
				| @ -4,10 +4,12 @@ import got from 'got'; | |||||||
| import delay from 'delay'; | import delay from 'delay'; | ||||||
| import pRetry from 'p-retry'; | import pRetry from 'p-retry'; | ||||||
| 
 | 
 | ||||||
| const IMAGE = 'npmjs/npm-docker-couchdb:1.6.1'; | const IMAGE = 'semanticrelease/npm-registry-docker:latest'; | ||||||
| const SERVER_PORT = 15986; | const SERVER_PORT = 15986; | ||||||
| const COUCHDB_PORT = 5984; | const COUCHDB_PORT = 5984; | ||||||
| const SERVER_HOST = 'localhost'; | const SERVER_HOST = 'localhost'; | ||||||
|  | const COUCHDB_USER = 'admin'; | ||||||
|  | const COUCHDB_PASSWORD = 'password'; | ||||||
| const NPM_USERNAME = 'integration'; | const NPM_USERNAME = 'integration'; | ||||||
| const NPM_PASSWORD = 'suchsecure'; | const NPM_PASSWORD = 'suchsecure'; | ||||||
| const NPM_EMAIL = 'integration@test.com'; | const NPM_EMAIL = 'integration@test.com'; | ||||||
| @ -15,7 +17,7 @@ const docker = new Docker(); | |||||||
| let container; | let container; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Download the `npm-docker-couchdb` Docker image, create a new container and start it. |  * Download the `npm-registry-docker` Docker image, create a new container and start it. | ||||||
|  */ |  */ | ||||||
| async function start() { | async function start() { | ||||||
|   await getStream(await docker.pull(IMAGE)); |   await getStream(await docker.pull(IMAGE)); | ||||||
| @ -24,10 +26,11 @@ async function start() { | |||||||
|     Tty: true, |     Tty: true, | ||||||
|     Image: IMAGE, |     Image: IMAGE, | ||||||
|     PortBindings: {[`${COUCHDB_PORT}/tcp`]: [{HostPort: `${SERVER_PORT}`}]}, |     PortBindings: {[`${COUCHDB_PORT}/tcp`]: [{HostPort: `${SERVER_PORT}`}]}, | ||||||
|  |     Env: [`COUCHDB_USER=${COUCHDB_USER}`, `COUCHDB_PASSWORD=${COUCHDB_PASSWORD}`], | ||||||
|   }); |   }); | ||||||
| 
 | 
 | ||||||
|   await container.start(); |   await container.start(); | ||||||
|   await delay(3000); |   await delay(4000); | ||||||
| 
 | 
 | ||||||
|   try { |   try { | ||||||
|     // Wait for the registry to be ready
 |     // Wait for the registry to be ready
 | ||||||
| @ -37,13 +40,13 @@ async function start() { | |||||||
|       factor: 2, |       factor: 2, | ||||||
|     }); |     }); | ||||||
|   } catch (err) { |   } catch (err) { | ||||||
|     throw new Error(`Couldn't start npm-docker-couchdb after 2 min`); |     throw new Error(`Couldn't start npm-registry-docker after 2 min`); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   // Create user
 |   // Create user
 | ||||||
|   await got(`http://${SERVER_HOST}:${SERVER_PORT}/_users/org.couchdb.user:${NPM_USERNAME}`, { |   await got(`http://${SERVER_HOST}:${SERVER_PORT}/_users/org.couchdb.user:${NPM_USERNAME}`, { | ||||||
|     json: true, |     json: true, | ||||||
|     auth: 'admin:admin', |     auth: `${COUCHDB_USER}:${COUCHDB_PASSWORD}`, | ||||||
|     method: 'PUT', |     method: 'PUT', | ||||||
|     body: { |     body: { | ||||||
|       _id: `org.couchdb.user:${NPM_USERNAME}`, |       _id: `org.couchdb.user:${NPM_USERNAME}`, | ||||||
| @ -66,7 +69,7 @@ const authEnv = { | |||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Stop and remote the `npm-docker-couchdb` Docker container. |  * Stop and remote the `npm-registry-docker` Docker container. | ||||||
|  */ |  */ | ||||||
| async function stop() { | async function stop() { | ||||||
|   await container.stop(); |   await container.stop(); | ||||||
|  | |||||||
| @ -16,11 +16,9 @@ const requireNoCache = proxyquire.noPreserveCache(); | |||||||
| 
 | 
 | ||||||
| // Environment variables used with semantic-release cli (similar to what a user would setup)
 | // Environment variables used with semantic-release cli (similar to what a user would setup)
 | ||||||
| const env = { | const env = { | ||||||
|  |   ...npmRegistry.authEnv, | ||||||
|   GH_TOKEN: gitbox.gitCredential, |   GH_TOKEN: gitbox.gitCredential, | ||||||
|   GITHUB_URL: mockServer.url, |   GITHUB_URL: mockServer.url, | ||||||
|   NPM_EMAIL: 'integration@test.com', |  | ||||||
|   NPM_USERNAME: 'integration', |  | ||||||
|   NPM_PASSWORD: 'suchsecure', |  | ||||||
|   TRAVIS: 'true', |   TRAVIS: 'true', | ||||||
|   CI: 'true', |   CI: 'true', | ||||||
|   TRAVIS_BRANCH: 'master', |   TRAVIS_BRANCH: 'master', | ||||||
| @ -29,9 +27,9 @@ const env = { | |||||||
| // Environment variables used only for the local npm command used to do verification
 | // Environment variables used only for the local npm command used to do verification
 | ||||||
| const testEnv = { | const testEnv = { | ||||||
|   ...process.env, |   ...process.env, | ||||||
|  |   ...npmRegistry.authEnv, | ||||||
|   npm_config_registry: npmRegistry.url, |   npm_config_registry: npmRegistry.url, | ||||||
|   NPM_EMAIL: 'integration@test.com', |   LEGACY_TOKEN: Buffer.from(`${env.NPM_USERNAME}:${env.NPM_PASSWORD}`, 'utf8').toString('base64'), | ||||||
|   LEGACY_TOKEN: Buffer.from(`${process.env.NPM_USERNAME}:${process.env.NPM_PASSWORD}`, 'utf8').toString('base64'), |  | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| const cli = require.resolve('../bin/semantic-release'); | const cli = require.resolve('../bin/semantic-release'); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user