chore(tools): tests in a docker container
This commit is contained in:
		
				
					committed by
					
						
						mrugesh mohapatra
					
				
			
			
				
	
			
			
			
						parent
						
							01edc58a2a
						
					
				
				
					commit
					aa6305778f
				
			
							
								
								
									
										2
									
								
								Dockerfile.tests
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								Dockerfile.tests
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,2 @@
 | 
				
			|||||||
 | 
					FROM node:lts
 | 
				
			||||||
 | 
					RUN apt-get update && apt-get install -y --no-install-recommends gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget
 | 
				
			||||||
@@ -108,8 +108,15 @@ async function runTests() {
 | 
				
			|||||||
        logLevel: 0
 | 
					        logLevel: 0
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
      browser = await puppeteer.launch({
 | 
					      browser = await puppeteer.launch({
 | 
				
			||||||
        args: ['--no-sandbox']
 | 
					        args: [
 | 
				
			||||||
 | 
					          // Required for Docker version of Puppeteer
 | 
				
			||||||
 | 
					          '--no-sandbox',
 | 
				
			||||||
 | 
					          '--disable-setuid-sandbox',
 | 
				
			||||||
 | 
					          // This will write shared memory files into /tmp instead of /dev/shm,
 | 
				
			||||||
 | 
					          // because Docker’s default for /dev/shm is 64MB
 | 
				
			||||||
 | 
					          '--disable-dev-shm-usage'
 | 
				
			||||||
          // dumpio: true
 | 
					          // dumpio: true
 | 
				
			||||||
 | 
					        ]
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
      global.Worker = createPseudoWorker(await newPageContext(browser));
 | 
					      global.Worker = createPseudoWorker(await newPageContext(browser));
 | 
				
			||||||
      page = await newPageContext(browser);
 | 
					      page = await newPageContext(browser);
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										25
									
								
								docker-compose.tests.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								docker-compose.tests.yml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,25 @@
 | 
				
			|||||||
 | 
					# Docker Compose file for FreeCodeCamp
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					# Before run tests, bootstrap project with commands from a docker-compose.yml
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					# Note, first run takes a long time.
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					# Run with:
 | 
				
			||||||
 | 
					#   npm run docker:test -- -c "npm run test"
 | 
				
			||||||
 | 
					# or
 | 
				
			||||||
 | 
					#   npm run docker:test -- -c "npm run test:curriculum"
 | 
				
			||||||
 | 
					#   npm run docker:test -- -c "npm run test:client"
 | 
				
			||||||
 | 
					#   npm run docker:test -- -c "npm run test:server"
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					# If need to test one challenge:
 | 
				
			||||||
 | 
					#   npm run docker:test -- -c "cd curriculum && npm run test -f 'Title of Challenge'"
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					version: '3'
 | 
				
			||||||
 | 
					services:
 | 
				
			||||||
 | 
					  tests:
 | 
				
			||||||
 | 
					    build:
 | 
				
			||||||
 | 
					      context: .
 | 
				
			||||||
 | 
					      dockerfile: Dockerfile.tests
 | 
				
			||||||
 | 
					    volumes:
 | 
				
			||||||
 | 
					      - .:/app
 | 
				
			||||||
 | 
					    working_dir: /app
 | 
				
			||||||
@@ -12,7 +12,7 @@
 | 
				
			|||||||
    "docker:install": "npm run docker:bash -- -c \"npm install\"",
 | 
					    "docker:install": "npm run docker:bash -- -c \"npm install\"",
 | 
				
			||||||
    "docker:install2": "docker-compose run --rm -u root freecodecamp bash -c \"npm install -g npm@5.7.1 && su node -c 'npm install'\"",
 | 
					    "docker:install2": "docker-compose run --rm -u root freecodecamp bash -c \"npm install -g npm@5.7.1 && su node -c 'npm install'\"",
 | 
				
			||||||
    "docker:seed": "npm run docker:bash -- -c \"npm run seed\"",
 | 
					    "docker:seed": "npm run docker:bash -- -c \"npm run seed\"",
 | 
				
			||||||
    "docker:test": "npm run docker:bash -- -c \"npm run test\"",
 | 
					    "docker:test": "docker-compose -f docker-compose.tests.yml run --rm tests bash",
 | 
				
			||||||
    "ensure-env": "cross-env DEBUG=fcc:* node ./tools/scripts/ensure-env.js",
 | 
					    "ensure-env": "cross-env DEBUG=fcc:* node ./tools/scripts/ensure-env.js",
 | 
				
			||||||
    "format": "npm run lint -- --fix",
 | 
					    "format": "npm run lint -- --fix",
 | 
				
			||||||
    "hooks:install": "node node_modules/husky/husky.js install",
 | 
					    "hooks:install": "node node_modules/husky/husky.js install",
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user