diff --git a/.github/workflows/build-production-images.yml b/.github/workflows/build-production-images.yml new file mode 100644 index 0000000..52d2ba8 --- /dev/null +++ b/.github/workflows/build-production-images.yml @@ -0,0 +1,45 @@ +name: build-production-images + +on: + push: + branches: + - master + tags: + - v* + +jobs: + prepare: + runs-on: ubuntu-latest + env: + CARGO_MAKE_VERSION: 0.26.1 + steps: + - name: Download cargo-make + run: | + curl -o /tmp/cargo-make.zip -sL https://github.com/sagiegurari/cargo-make/releases/download/${CARGO_MAKE_VERSION}/cargo-make-v${CARGO_MAKE_VERSION}-x86_64-unknown-linux-musl.zip + unzip /tmp/cargo-make.zip cargo-make-v${CARGO_MAKE_VERSION}-x86_64-unknown-linux-musl/cargo-make -d /tmp/ + mv /tmp/cargo-make-v${CARGO_MAKE_VERSION}-x86_64-unknown-linux-musl/cargo-make /tmp/ + - name: Save downloaded binary as an artifact + uses: actions/upload-artifact@v1 + with: + name: cargo-make-bin + path: /tmp/cargo-make + build: + needs: prepare + runs-on: ubuntu-latest + strategy: + matrix: + service: [bff, frontend] + steps: + - uses: actions/checkout@v2 + - name: Get cargo-make binary + uses: actions/download-artifact@v1 + with: + name: cargo-make-bin + path: bin/ + # See: + # - https://github.com/actions/upload-artifact/issues/38 + # - https://github.com/actions/download-artifact/issues/14 + - name: Restore the permissions + run: chmod +x bin/cargo-make + - name: make + run: bin/cargo-make make --makefile tasks/build-production-images.toml ${{ matrix.service }} diff --git a/.github/workflows/test-all.yml b/.github/workflows/test-all.yml new file mode 100644 index 0000000..380061d --- /dev/null +++ b/.github/workflows/test-all.yml @@ -0,0 +1,23 @@ +name: test-all-services + +on: + push: + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + service: [bff, frontend] + node-version: [12.x] + env: + working-directory: ${{ matrix.service }} + steps: + - uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - uses: actions/checkout@v2 + - run: npm install + working-directory: ${{ matrix.service }} + - run: npm run test:coverage + working-directory: ${{ matrix.service }} diff --git a/README.md b/README.md index 61886a6..cebb710 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # console +![GitHub Actions status for "test-all-services"](https://github.com/mazgi/console/workflows/test-all-services/badge.svg) + ## How to run ### Download cargo-make diff --git a/bff/package.json b/bff/package.json index c085958..61ea68c 100644 --- a/bff/package.json +++ b/bff/package.json @@ -6,7 +6,7 @@ "typeorm": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js", "lint": "eslint \"src/**\"", "test": "jest", - "coverage": "jest --coverage", + "test:coverage": "jest --coverage", "build": "webpack", "build:debug": "webpack --mode development", "start": "node dist/main.js", diff --git a/frontend/__mocks__/next/config.ts b/frontend/__mocks__/next/config.ts new file mode 100644 index 0000000..c255cb5 --- /dev/null +++ b/frontend/__mocks__/next/config.ts @@ -0,0 +1,7 @@ +// This mock function is important when using Jest with Next.js. +// See https://spectrum.chat/next-js/general/how-to-setup-jest-tests-to-use-publicruntimeconfig~27f8cee1-d4a4-4b68-bb62-ea6562a77544 +export default (): {} => ({ + env: {}, + publicRuntimeConfig: {}, + serverRuntimeConfig: {} +}) diff --git a/frontend/package.json b/frontend/package.json index 7d28a40..0daa9ed 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -3,7 +3,7 @@ "dev": "next", "lint": "eslint \"src/**\"", "test": "jest", - "coverage": "jest --coverage", + "test:coverage": "jest --coverage", "build": "next build", "start": "next start" },