From 21338e2d04240ef495fd991207d1831a2083a286 Mon Sep 17 00:00:00 2001 From: Stuart Clark <stu@rtclark.net> Date: Sun, 2 Jan 2022 14:35:28 +1100 Subject: [PATCH] feat(#19): add Github Actions workflow (#21) * feat(#19): add WIP workflow * chore(#19): add tests to ci --- .github/workflows/ci.yml | 60 +++++++++++++++++++++++++++++ nuxt/components/StuartClark.test.js | 21 ++++++++++ 2 files changed, 81 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 nuxt/components/StuartClark.test.js diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..0a1d627 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,60 @@ +name: ci + +on: + push: + branches: + - main + - develop + pull_request: + branches: + - main + - develop + +jobs: + ci: + runs-on: ${{ matrix.os }} + + strategy: + matrix: + os: [ubuntu-latest] + node: [14] + + steps: + - name: Checkout ๐ + uses: actions/checkout@master + + - name: Setup node env ๐ + uses: actions/setup-node@v2.1.5 + with: + node-version: ${{ matrix.node }} + check-latest: true + + - name: Get yarn cache directory path ๐ + id: yarn-cache-dir-path + run: cd nuxt && echo "::set-output name=dir::$(yarn cache dir)" + + - name: Cache node_modules ๐ฆ + uses: actions/cache@v2.1.4 + id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + + - name: Install dependencies ๐จ๐ปโ๐ป + run: cd nuxt && yarn + + - name: Run linting ๐ + run: cd nuxt && yarn lint + + - name: Run tests ๐งช + run: cd nuxt && yarn test + + - uses: codecov/codecov-action@v2 + with: + files: ./nuxt/coverage/clover.xml + name: codecov-umbrella + fail_ci_if_error: true + verbose: true + diff --git a/nuxt/components/StuartClark.test.js b/nuxt/components/StuartClark.test.js new file mode 100644 index 0000000..2713c42 --- /dev/null +++ b/nuxt/components/StuartClark.test.js @@ -0,0 +1,21 @@ +import { mount } from '@vue/test-utils' +import StuartClark from './StuartClark.vue' + +const mocks = { + $store: { + state: { + config: { + title: undefined, + social: {}, + }, + }, + }, +} +const stubs = ['LogoDrupal', 'LogoGithub', 'LogoTwitter'] + +describe('StuartClark', () => { + test('is a Vue instance', () => { + const wrapper = mount(StuartClark, { mocks, stubs }) + expect(wrapper.vm).toBeTruthy() + }) +})