Skip to content

952 include configuration for git mode in libms #840

952 include configuration for git mode in libms

952 include configuration for git mode in libms #840

Workflow file for this run

name: Library microservice
on:
push:
paths:
- 'servers/lib/**'
pull_request:
paths:
- 'servers/lib/**'
workflow_dispatch:
jobs:
test-lib-ms:
name: Test library microservice
strategy:
matrix:
os: [windows-latest, ubuntu-latest]
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: servers/lib
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
cache: "yarn"
cache-dependency-path: "**/yarn.lock"
- name: Install pm2 and jest
run: |
npm install -g pm2
npm install -g jest
- name: Run the linting checks
run: |
yarn install
yarn syntax
- name: Build the lib microservice
run: |
yarn install
yarn build
- name: Run all tests
env:
PORT: 4001
LOCAL_PATH: ${{ github.workspace }}/files
MODE: local
LOG_LEVEL: debug
APOLLO_PATH: /lib
run: |
yarn install
yarn build
yarn test:all
- name: Start http mode
env:
PORT: 4003
LOCAL_PATH: ${{ github.workspace }}/files
MODE: local
LOG_LEVEL: debug
APOLLO_PATH: /lib
run: |
yarn install
yarn build
yarn start:pm2
- name: Check server is running (Windows)
if: runner.os == 'Windows'
env:
PORT: 4003
uses: nick-fields/retry@v3
with:
timeout_seconds: 10
max_attempts: 4
command: "Invoke-WebRequest -Uri http://localhost:${{ env.PORT }}/lib/files -Method Head -UseBasicParsing"
- name: Check server is running (Linux)
if: runner.os != 'Windows'
env:
PORT: 4003
uses: nick-fields/retry@v3
with:
timeout_seconds: 10
max_attempts: 4
command: "curl -f -LI http://localhost:${{ env.PORT }}/lib/files"
- name: Run http test
env:
PORT: 4003
LOCAL_PATH: ${{ github.workspace }}/files
MODE: local
LOG_LEVEL: debug
APOLLO_PATH: /lib
run: |
yarn test:http-github
- name: Stop http mode
run: |
yarn stop:pm2
- name: Upload test coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: servers/lib/coverage/clover.xml
flags: lib-microservice-tests
publish-npm-package:
if: |
github.event_name == 'push' &&
(startsWith(github.ref, 'refs/heads/feature/') || startsWith(github.ref, 'refs/heads/release-v'))
name: Publish NPM Package to GitHub Packages
runs-on: ubuntu-latest
needs: test-lib-ms
permissions:
packages: write
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
cache: "yarn"
cache-dependency-path: "**/yarn.lock"
always-auth: true
registry-url: 'https://npm.pkg.github.com/'
- name: Publish npm package
run: |
# copy README.md to project root
cp servers/lib/README.md .
cd servers/lib
yarn install
yarn build
yarn publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
get_version:
name: Get version
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Install jq
run: sudo apt-get install -y jq
- name: get version
id: get_version
run: |
version=`cat ./servers/lib/package.json | jq -r '.version'`
echo "version=$version" >> $GITHUB_OUTPUT
outputs:
version: ${{ steps.get_version.outputs.version }}
publish-docker-image-ghcr:
if: |
github.event_name == 'push' &&
(startsWith(github.ref, 'refs/heads/feature/') || startsWith(github.ref, 'refs/heads/release-v'))
name: Publish Docker image (GHCR)
needs: [get_version, test-lib-ms]
uses: ./.github/workflows/docker-ghcr.yml
with:
image-name: libms
version: ${{ needs.get_version.outputs.version }}
dockerfile: libms.dockerfile
secrets: inherit
publish-docker-image-dockerhub:
if: |
github.event_name == 'push' &&
(startsWith(github.ref, 'refs/heads/feature/') || startsWith(github.ref, 'refs/heads/release-v'))
name: Publish Docker image (DockerHub)
needs: [get_version, test-lib-ms]
uses: ./.github/workflows/docker-dockerhub.yml
with:
image-name: libms
version: ${{ needs.get_version.outputs.version }}
dockerfile: libms.dockerfile
readme-file: servers/lib/DOCKER.md
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_SCOPE: ${{ secrets.DOCKERHUB_SCOPE }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}