Skip to content

Merge pull request #2 from Qlever-LLC/dependabot/github_actions/actio… #12

Merge pull request #2 from Qlever-LLC/dependabot/github_actions/actio…

Merge pull request #2 from Qlever-LLC/dependabot/github_actions/actio… #12

# Copyright 2022 Qlever LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: "Build and Test"
on:
push:
jobs:
build:
uses: qlever-llc/workflows/.github/workflows/build-and-push-service.yml@master
secrets:
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_repo: ${{ secrets.DOCKER_REPO }}
snyk_org: ${{ secrets.SNYK_ORG }}
# Actual secrets
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }}
snyk_token: ${{ secrets.SNYK_TOKEN }}
cosign_key: ${{ secrets.COSIGN_KEY }}
cosign_password: ${{ secrets.COSIGN_PASSWORD }}
setup:
runs-on: ubuntu-latest
outputs:
image: ${{ steps.image.outputs.image }}
steps:
- name: Get image tag
id: image
run: |
SHA=${GITHUB_SHA::7}
# GHCR does not like upper case
REPO=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')
echo "::set-output name=image::ghcr.io/${REPO}:sha-${SHA}"
test:
needs:
- setup
- build
runs-on: ubuntu-latest
services:
oada:
image: ${{ needs.setup.outputs.image }}
# Needed for DooD
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
ports:
- 80
steps:
- name: Check out repository
uses: actions/checkout@v4
- uses: ./.github/actions/test
with:
api: "http://localhost:${{ job.services.oada.ports['80'] }}"
- name: Print OADA logs
if: ${{ always() }}
continue-on-error: true
shell: bash
run: |
docker run \
--rm \
-v "/var/run/docker.sock:/var/run/docker.sock" \
${{ needs.setup.outputs.image }} logs
container-test:
needs:
- setup
- build
runs-on: ubuntu-latest
services:
oada:
image: ${{ needs.setup.outputs.image }}
# Needed for DooD
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
ports:
- 80
container: node
steps:
- name: Check out repository
uses: actions/checkout@v4
- uses: ./.github/actions/test
with:
api: "http://oada"
- name: Print OADA logs
if: ${{ always() }}
continue-on-error: true
shell: bash
run: |
docker run \
--rm \
-v "/var/run/docker.sock:/var/run/docker.sock" \
${{ needs.setup.outputs.image }} logs