eggjs / egg-ci
Showing 1 of 6 files from the diff.
Other files ignored by Codecov

@@ -38,11 +38,50 @@
Loading
38 38
  nyc: false,
39 39
  license: false,
40 40
  command: 'ci',
41 +
  service: {},
41 42
  ...pkg.ci,
42 43
};
43 44
44 45
config.versions = arrayify(config.version);
45 -
// if (config.services) config.services = arrayify(config.services);
46 +
47 +
let mysqlServer = '';
48 +
if (config.service.mysql) {
49 +
  // service only support on linux
50 +
  config.os = 'linux';
51 +
  const mysql = {
52 +
    version: '8',
53 +
    db: 'unittest',
54 +
    ...config.service.mysql,
55 +
  };
56 +
  mysqlServer = `
57 +
    services:
58 +
      mysql:
59 +
        image: mysql:${mysql.version}
60 +
        env:
61 +
          MYSQL_ALLOW_EMPTY_PASSWORD: true
62 +
          MYSQL_DATABASE: ${mysql.db}
63 +
        ports:
64 +
          - 3306:3306
65 +
        options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5
66 +
`;
67 +
}
68 +
69 +
let redisServer = '';
70 +
if (config.service['redis-server']) {
71 +
  // service only support on linux
72 +
  config.os = 'linux';
73 +
  const redis = {
74 +
    version: '6',
75 +
    ...config.service['redis-server'],
76 +
  };
77 +
  redisServer = `
78 +
    # https://github.com/marketplace/actions/redis-server-in-github-actions#usage
79 +
    - name: Start Redis
80 +
      uses: supercharge/redis-github-action@1.4.0
81 +
      with:
82 +
        redis-version: ${redis.version}
83 +
`;
84 +
}
46 85
47 86
const os = arrayify(config.os).map(name => {
48 87
  if (name === 'linux') name = 'ubuntu';
@@ -53,7 +92,9 @@
Loading
53 92
  .replace('{{github_node_version}}', config.versions.join(', '))
54 93
  .replace('{{github_os}}', os.join(', '))
55 94
  .replace('{{github_command_ci}}', config.command)
56 -
  .replace('{{github_npm_install}}', config.npminstall ? 'npm i -g npminstall && npminstall' : 'npm i');
95 +
  .replace('{{github_npm_install}}', config.npminstall ? 'npm i -g npminstall && npminstall' : 'npm i')
96 +
  .replace('{{mysql}}', mysqlServer)
97 +
  .replace('{{redis-server}}', redisServer);
57 98
const ymlName = '.github/workflows/nodejs.yml';
58 99
const ymlPath = path.join(root, ymlName);
59 100
fs.mkdirSync(path.dirname(ymlPath), { recursive: true });
Files Coverage
install.js 99.19%
Project Totals (1 files) 99.19%
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading