Merge pull request #1 from abhishekinstnt/abhishek_GithubAction2 #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI mediator | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- "**" | |
paths: | |
- 'aries/agents/mediator/**' | |
env: | |
DOCKER_BUILDKIT: 1 | |
MAIN_BRANCH: main | |
RUST_TOOLCHAIN_VERSION: 1.79.0 | |
jobs: | |
setup-variables: | |
runs-on: ubuntu-22.04 | |
outputs: | |
PUBLISH_VERSION: ${{ steps.run-info.outputs.publish-version }} | |
RELEASE: ${{ steps.run-info.outputs.release }} | |
PRERELEASE: ${{ steps.run-info.outputs.pre-release }} | |
BRANCH_NAME: ${{ steps.run-info.outputs.branch-name }} | |
IS_FORK: ${{ steps.run-info.outputs.is-fork }} | |
SKIP_CI: ${{ steps.skip-info.outputs.skip-ci }} | |
steps: | |
- name: "Git checkout" | |
uses: actions/checkout@v1 | |
- name: "Construct CI run-info" | |
id: run-info | |
uses: ./.github/actions/construct-run-info | |
- name: "Detect CI skip steps" | |
id: skip-info | |
uses: ./.github/actions/detect-skip-info | |
check-variables: | |
runs-on: ubuntu-22.04 | |
needs: setup-variables | |
steps: | |
- name: "Print outputs" | |
run: | | |
echo "PUBLISH_VERSION ${{ needs.setup-variables.outputs.PUBLISH_VERSION }}" | |
echo "RELEASE ${{ needs.setup-variables.outputs.RELEASE }}" | |
echo "PRERELEASE ${{ needs.setup-variables.outputs.PRERELEASE }}" | |
echo "BRANCH_NAME ${{ needs.setup-variables.outputs.BRANCH_NAME }}" | |
echo "IS_FORK ${{ needs.setup-variables.outputs.IS_FORK }}" | |
echo "SKIP_CI ${{ needs.setup-variables.outputs.SKIP_CI }}" | |
test-integration-mediator: | |
needs: [ setup-variables ] | |
if: ${{ needs.setup-variables.outputs.SKIP_CI != 'true' }} | |
runs-on: ubuntu-22.04 | |
services: | |
mysql: | |
image: mysql:latest | |
env: | |
MYSQL_DATABASE: mediator-persistence.mysql | |
MYSQL_USER: admin | |
MYSQL_PASSWORD: github.ci.password.no.prod | |
MYSQL_ROOT_PASSWORD: github.ci.password.no.prod | |
ports: | |
- '3326:3306' | |
env: | |
MYSQL_URL: mysql://admin:github.ci.password.no.prod@localhost:3326/mediator-persistence.mysql | |
steps: | |
- name: "Git checkout" | |
uses: actions/checkout@v3 | |
- name: "Setup rust testing environment" | |
uses: ./.github/actions/setup-testing-rust | |
with: | |
rust-toolchain-version: ${{ env.RUST_TOOLCHAIN_VERSION }} | |
skip-docker-setup: true | |
skip-vdrproxy-setup: true | |
- name: Install prerequisites (sqlx) | |
# uses: Swatinem/rust-cache@v2 | |
run: cargo install sqlx-cli | |
- name: Setup database | |
run: DATABASE_URL=${MYSQL_URL} sqlx migrate run --source aries/agents/mediator/migrations | |
- name: "Run mediator integration tests" | |
run: cargo run --bin mediator & sleep 5 && cargo test --verbose --package mediator -- --nocapture; | |
- name: "Collect docker logs on failure" | |
if: failure() | |
uses: ./.github/actions/upload-docker-logs | |
with: | |
name: "docker-services-${{ github.job }}" | |
docker-mediator-build: | |
needs: [ test-integration-mediator, setup-variables ] | |
if: ${{ needs.setup-variables.outputs.SKIP_CI != 'true' }} | |
runs-on: ubuntu-22.04 | |
env: | |
DOCKER_IMAGE: mediator:${{ needs.setup-variables.outputs.BRANCH_NAME }} | |
outputs: | |
image-name: ${{ steps.meta.outputs.tags }} | |
steps: | |
- name: "Git checkout" | |
uses: actions/checkout@v3 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: "Build and cache docker image" | |
uses: ./.github/actions/build-image | |
with: | |
docker-img: ${{ env.DOCKER_IMAGE }} | |
dockerfile-path: "aries/agents/mediator/Dockerfile" | |
branch-name: ${{ needs.setup-variables.outputs.BRANCH_NAME }} | |
branch-main: ${{ env.MAIN_BRANCH }} | |
docker-repo-local-name: mediator | |
- name: "Publish versioned docker image" | |
if: ${{ needs.workflow-setup.outputs.RELEASE == 'true' || needs.workflow-setup.outputs.PRERELEASE == 'true' }} | |
uses: ./.github/actions/publish-image | |
with: | |
docker-img: ${{ env.DOCKER_IMAGE }} | |
publish-version: ${{ needs.setup-variables.outputs.PUBLISH_VERSION }} | |
env: | |
URL_DOCKER_REGISTRY: ghcr.io # Required by .github/actions/publish-image |