Skip to content

test fix

test fix #1309

name: test and publish
on: push
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: "18.13"
- name: Authenticate with private NPM package
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
- name: Install
run: npm ci
- name: Run format test
run: npm run test:format
- name: Run license test
run: npm run test:license
- name: Client - Install
run: cd client && npm ci
# - name: Client - audit
# run: cd client && npm run test:audit
- name: Client - Run lint test
run: cd client && npm run test:lint
- name: Client - Run types test
run: cd client && npm run test:types
test-e2e:
name: test e2e
runs-on: ubuntu-latest
steps:
- name: Authenticate with private NPM package
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
- uses: actions/checkout@v2
- name: build + run app in docker compose
run: docker compose up -d
- name: check services running
run: docker ps
- name: cypress - run tests
run: make test-e2e-exec
publish-check:
name: publish check
needs:
- test
- test-e2e
runs-on: ubuntu-latest
outputs:
is_release: ${{ steps.is_release.outputs.is_release }}
steps:
- id: is_release
run: |
if [[ ${{ github.event.ref }} =~ ^refs/tags/[0-9]+\.[0-9]+\.[0-9]+(-[a-z0-9.]*)?$ ]]; then
echo ::set-output name=is_release::true
fi
build-and-publish:
name: build + push docker image
runs-on: ubuntu-latest
needs:
- publish-check
- test
- test-e2e
if: needs.publish-check.outputs.is_release || github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v2
- name: docker tag
id: tag
run: |
IMAGE_TAG=${GITHUB_SHA}
echo ::set-output name=image_tag::${IMAGE_TAG}
- name: docker login
run: docker login -u ${{ secrets.DOCKER_LOGIN }} -p ${{ secrets.DOCKER_PASSWORD }}
- name: Docker build
run: export DOCKER_IMAGE=mentorpal/mentor-client:${{ steps.tag.outputs.image_tag }} && make docker-build
- name: docker tag release as version
if: needs.publish-check.outputs.is_release == 'true'
run: docker tag "mentorpal/mentor-client:${{ steps.tag.outputs.image_tag }}" "mentorpal/mentor-client:${GITHUB_REF#refs/tags/}"
- name: docker tag main as latest
if: github.ref == 'refs/heads/main'
run: docker tag "mentorpal/mentor-client:${{ steps.tag.outputs.image_tag }}" "mentorpal/mentor-client:latest"
- name: docker push
run: docker push --all-tags mentorpal/mentor-client