From 46a5586573a8e8ef82266375032bcd15a91fb0a3 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Fri, 17 Jun 2022 10:50:54 +1000 Subject: [PATCH] Add GitHub Action CI --- .github/workflows/ci.yml | 63 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..1f505ba --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,63 @@ +name: CI + +on: + push: + branches: + - "master" + pull_request: + +jobs: + examples_build_and_test: + strategy: + matrix: + example: + [ + web-chat, + eth-pm, + eth-pm-wallet-encryption, + relay-reactjs-chat, + store-reactjs-chat, + relay-angular-chat, + ] + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Install NodeJS + uses: actions/setup-node@v2 + with: + node-version: "16" + + - name: Check if `yarn` or `npm` is used. + id: use-yarn + shell: bash + run: echo "::set-output name=lockfile::$(ls yarn.lock 2> /dev/null)" + working-directory: examples/${{ matrix.example }} + + - name: (npm) Cache npm cache + if: steps.use-yarn.outputs.lockfile != 'yarn.lock' + uses: actions/cache@v2 + with: + path: ~/.npm + key: examples-node-v1-${{ hashFiles('**/package-lock.json') }} + + - name: (npm) ${{ matrix.example }} install using npm i + if: steps.use-yarn.outputs.lockfile != 'yarn.lock' + run: npm install + working-directory: examples/${{ matrix.example }} + + - name: (npm) ${{ matrix.example }} test + if: steps.use-yarn.outputs.lockfile != 'yarn.lock' + run: npm run test + working-directory: examples/${{ matrix.example }} + + - name: (yarn) ${{ matrix.example }} install using yarn + if: steps.use-yarn.outputs.lockfile == 'yarn.lock' + run: yarn install --frozen-lockfile + working-directory: examples/${{ matrix.example }} + + - name: (yarn) ${{ matrix.example }} test + if: steps.use-yarn.outputs.lockfile == 'yarn.lock' + run: echo "test skipped" # yarn test; tracked with https://github.com/status-im/js-waku/issues/563 + working-directory: examples/${{ matrix.example }}