diff --git a/.github/actions/shared-job-steps/action.yml b/.github/actions/shared-job-steps/action.yml new file mode 100644 index 0000000000..ddd39c2abc --- /dev/null +++ b/.github/actions/shared-job-steps/action.yml @@ -0,0 +1,38 @@ +name: job setup +description: 'Sets the shared steps for each job' + +inputs: + node-version: + description: 'The Node version to be setup' + required: true + node-env: + description: 'Node-Env for CI' + required: true + +runs: + using: composite + steps: + - uses: actions/checkout@v1 + with: + fetch-depth: 1 + - name: Use Node.js ${{ inputs.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ inputs.node-version }} + - name: Cache multiple paths + id: cache-package + uses: actions/cache@v2 + with: + path: | + **/node_modules + key: ${{ runner.os }}-${{ inputs.node-version }}-${{ hashFiles('**/package.json') }} + + - run: cp config.json.example config.json + + - name: npm install + if: steps.cache-package.outputs.cache-hit != 'true' + run: | + npm ci + env: + CI: true + NODE_ENV: test diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a91df5e54a..7d96f416ee 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,20 +12,12 @@ jobs: matrix: node-version: [14.x] steps: - - uses: actions/checkout@v1 - with: - fetch-depth: 1 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 + - name: Setup + uses: './.github/actions/shared-job-steps' with: node-version: ${{ matrix.node-version }} - - run: cp config.json.example config.json - - name: npm install - run: | - npm ci - env: - CI: true - NODE_ENV: test + node-env: 'test' + - run: npm run lint-no-fix apidoc: runs-on: ubuntu-latest @@ -37,11 +29,19 @@ jobs: with: fetch-depth: 1 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 + uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} + - name: Cache multiple paths + id: cache-package + uses: actions/cache@v2 + with: + path: | + **/node_modules + key: ${{ runner.os }}-${{ hashFiles('**/package.json') }} - run: cp config.json.example config.json - name: npm install + if: steps.cache-package.outputs.cache-hit != 'true' run: | npm ci env: @@ -58,9 +58,16 @@ jobs: with: fetch-depth: 1 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 + uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} + - name: Cache multiple paths + id: cache-package + uses: actions/cache@v2 + with: + path: | + **/node_modules + key: ${{ runner.os }}-${{ hashFiles('**/package.json') }} - run: cp config.json.example config.json - name: npm install run: | @@ -69,7 +76,7 @@ jobs: CI: true NODE_ENV: test - run: npm run test:sanity - + common: runs-on: ubuntu-latest strategy: @@ -112,7 +119,7 @@ jobs: CI: true NODE_ENV: test - run: npm run test:content - + api-unit: runs-on: ubuntu-latest strategy: