Skip to content

Commit

Permalink
cache testing redis install on github unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
daneryl committed Jan 24, 2022
1 parent 2fb64ac commit 4d3425e
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 8 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/ci_api_unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ jobs:
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
- name: install dependencies
run: yarn install

- name: Cache testing redis
id: cache-redis
uses: actions/cache@v2
with:
path: ./redis-bin
key: ${{ runner.os }}-yarn-${{ hashFiles('.redis_version') }}
- name: install redis for testing
if: steps.cache-redis.outputs.cache-hit != 'true'
run: yarn install_redis_for_testing

- run: sudo apt update
- run: sudo apt-get install poppler-utils
- run: curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
Expand Down
1 change: 1 addition & 0 deletions .redis_version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6.2.6
15 changes: 7 additions & 8 deletions app/api/utils/downloadRedis.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,19 @@ import { execSync } from 'child_process';
import path from 'path';

export const downloadRedis = () => {
const pathToBin = path.join(__dirname, '../../../redis-bin/redis-stable/src/redis-server');
const redis_version = (execSync('cat .redis_version').toString()).replace('\n', '');
const pathToBin = path.join(__dirname, `../../../redis-bin/redis-stable/src/redis-server`);
console.log(pathToBin);
if (fs.existsSync(pathToBin)) {
return;
}
console.log('Downloading redis...');
execSync(
`mkdir redis-bin && cd redis-bin
curl -O http://download.redis.io/redis-stable.tar.gz
tar xzvf redis-stable.tar.gz`,
{ stdio: 'ignore' }
);

execSync('cd redis-bin && tar xzvf redis-stable.tar.gz', { stdio: 'ignore' });
execSync('mkdir -p redis-bin', { stdio: 'ignore' });
execSync(`cd redis-bin && curl -O http://download.redis.io/releases/redis-${redis_version}.tar.gz` , { stdio: 'ignore' });
execSync(`cd redis-bin && tar xzvf redis-${redis_version}.tar.gz`, { stdio: 'ignore' });
execSync(`cd redis-bin && mv redis-${redis_version} redis-stable`, { stdio: 'ignore' });

console.log('Downloading redis... Done');
console.log('Installing redis...');
execSync(
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"watch-types": "tsc --noEmit --pretty --watch --preserveWatchOutput",
"emit-types": "node scripts/emitSchemaTypes.js",
"emitSocketEvent": "node ./scripts/run.js ./emitSocketEvent.js",
"install_redis_for_testing": "node ./scripts/run.js ./install_redis_for_testing.js",
"production-build": "./webpack/build.sh",
"run-production": "NODE_ENV=production node --max-http-header-size 20000 server.js",
"dev-server": "./node_modules/.bin/nodemon --max-http-header-size 20000 ./server.js --ignore 'app/dist/*' --watch 'app/api' --watch 'app/shared' --ext 'ts js tsx'",
Expand Down
2 changes: 2 additions & 0 deletions scripts/install_redis_for_testing.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import { downloadRedis } from '../app/api/utils/downloadRedis.js';
downloadRedis();

0 comments on commit 4d3425e

Please sign in to comment.