diff --git a/.github/actions/set-up-environment/action.yml b/.github/actions/set-up-environment/action.yml new file mode 100644 index 00000000..1f2c4348 --- /dev/null +++ b/.github/actions/set-up-environment/action.yml @@ -0,0 +1,17 @@ +name: 'Set up environment' +description: 'Sets up Node and installs dependencies' +runs: + using: 'composite' + steps: + - name: Set up Node + uses: actions/setup-node@v4 + with: + node-version: 18 + - name: Cache dependencies + uses: actions/cache@v4 + with: + path: ~/.npm + key: node-modules-${{ hashFiles('**/package-lock.json') }} + - name: Install dependencies + run: npm ci + shell: bash diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 446e5678..65b245fd 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -5,37 +5,19 @@ jobs: build: runs-on: ubuntu-latest steps: - - name: Checkout code + - name: Check out code uses: actions/checkout@v4 - - name: Setup Node - uses: actions/setup-node@v4 - with: - node-version: 18 - - name: Cache dependencies - uses: actions/cache@v4 - with: - path: ~/.npm - key: node-modules-${{ hashFiles('**/package-lock.json') }} - - name: Install dependencies - run: npm ci + - name: Set up environment + uses: ./.github/actions/set-up-environment - name: Build app run: npm run build unit_tests: needs: build runs-on: ubuntu-latest steps: - - name: Checkout code + - name: Check out code uses: actions/checkout@v4 - - name: Setup Node - uses: actions/setup-node@v4 - with: - node-version: 18 - - name: Cache dependencies - uses: actions/cache@v4 - with: - path: ~/.npm - key: node-modules-${{ hashFiles('**/package-lock.json') }} - - name: Install dependencies - run: npm ci + - name: Set up environment + uses: ./.github/actions/set-up-environment - name: Run tests run: npm test