Merge pull request #392 from lnis-uofu/gg_ci_cd_dev

Make CI Portable
This commit is contained in:
tangxifan 2021-10-19 08:33:38 -07:00 committed by GitHub
commit 5e912b3c51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 13 deletions

View File

@ -13,6 +13,8 @@ env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release BUILD_TYPE: Release
MAKEFLAGS: "-j8" MAKEFLAGS: "-j8"
DOCKER_REPO: ${{ secrets.DOCKER_REPO }}
REPO_OWNER: ${{ github.repository_owner }}
# Multiple job to tests # Multiple job to tests
jobs: jobs:
@ -24,6 +26,7 @@ jobs:
source_modified: ${{ steps.changes.outputs.status_code == '1' }} source_modified: ${{ steps.changes.outputs.status_code == '1' }}
force_upload: false force_upload: false
sha_short: ${{ steps.changes.outputs.sha_short }} sha_short: ${{ steps.changes.outputs.sha_short }}
docker_repo: ${{ steps.changes.outputs.docker_repo }}
steps: steps:
- name: Checkout OpenFPGA repo - name: Checkout OpenFPGA repo
uses: actions/checkout@v2 uses: actions/checkout@v2
@ -43,14 +46,22 @@ jobs:
echo "Current brnach is master forcing source_modified" echo "Current brnach is master forcing source_modified"
echo "::set-output name=status_code::1" echo "::set-output name=status_code::1"
fi fi
if [[ -n "${DOCKER_REPO}" ]]; then
echo "name=docker_repo::$REPO_OWNER"
echo "::set-output name=docker_repo::$REPO_OWNER"
else
echo "name=docker_repo::lnis-uofu"
echo "::set-output name=docker_repo::lnis-uofu"
fi
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
# Test the compilation compatibility # Test the compilation compatibility
linux_build: linux_build:
needs: change_detect needs: change_detect
if: ${{ fromJSON(needs.change_detect.outputs.source_modified) }} if: ${{ fromJSON(needs.change_detect.outputs.source_modified) }}
name: ${{ matrix.config.name }} name: ${{ matrix.config.name }}
runs-on: ubuntu-18.04 runs-on: ubuntu-18.04
container: ghcr.io/lnis-uofu/openfpga-build-${{ matrix.config.cc}} container: ghcr.io/${{ needs.change_detect.outputs.docker_repo }}/openfpga-build-${{ matrix.config.cc}}
# Branch on different OS and settings # Branch on different OS and settings
strategy: strategy:
fail-fast: false fail-fast: false
@ -181,7 +192,7 @@ jobs:
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1 uses: docker/setup-buildx-action@v1
- name: Login to GitHub Container Registry - name: Login to GitHub Container Registry
if: ${{ (github.ref == 'refs/heads/master') || (needs.change_detect.outputs.force_upload == true) }} if: ${{ (github.ref == 'refs/heads/master' && (env.DOCKER_REPO)) || (needs.change_detect.outputs.force_upload == true) }}
uses: docker/login-action@v1 uses: docker/login-action@v1
with: with:
registry: ghcr.io registry: ghcr.io
@ -192,15 +203,15 @@ jobs:
with: with:
context: . context: .
file: ./docker/Dockerfile.master file: ./docker/Dockerfile.master
push: ${{ github.ref == 'refs/heads/master' || needs.change_detect.outputs.force_upload }} push: ${{ (github.ref == 'refs/heads/master' && (env.DOCKER_REPO)) || needs.change_detect.outputs.force_upload }}
tags: | tags: |
ghcr.io/lnis-uofu/openfpga-master:latest ghcr.io/${{ needs.change_detect.outputs.docker_repo }}/openfpga-master:latest
ghcr.io/lnis-uofu/openfpga-master:${{ needs.change_detect.outputs.sha_short }} ghcr.io/${{ needs.change_detect.outputs.docker_repo }}/openfpga-master:${{ needs.change_detect.outputs.sha_short }}
linux_regression_tests: linux_regression_tests:
name: linux_regression_tests name: linux_regression_tests
runs-on: ubuntu-18.04 runs-on: ubuntu-18.04
container: ghcr.io/lnis-uofu/openfpga-env needs: [linux_build, change_detect]
needs: linux_build container: ghcr.io/${{ needs.change_detect.outputs.docker_repo }}/openfpga-env
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
@ -248,7 +259,7 @@ jobs:
if: ${{ !fromJSON(needs.change_detect.outputs.source_modified) }} if: ${{ !fromJSON(needs.change_detect.outputs.source_modified) }}
name: docker_regression_tests name: docker_regression_tests
runs-on: ubuntu-18.04 runs-on: ubuntu-18.04
container: ghcr.io/lnis-uofu/openfpga-master:latest container: ghcr.io/${{ needs.change_detect.outputs.docker_repo }}/openfpga-master:latest
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:

View File

@ -1,13 +1,30 @@
name: Build docker CI images name: Build docker CI images
on: on:
- workflow_dispatch - workflow_dispatch
# Environment variables
env:
DOCKER_REPO: ${{ secrets.DOCKER_REPO }}
REPO_OWNER: ${{ github.repository_owner }}
jobs: jobs:
base_images: base_images:
name: Push Docker images name: Push Docker images
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: ${{ secrets.DOCKER_REPO }}
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Check for source code changes
id: changes
run: |
if [[ -n "${DOCKER_REPO}" ]]; then
echo "name=docker_repo::$REPO_OWNER"
echo "::set-output name=docker_repo::$REPO_OWNER"
else
echo "name=docker_repo::lnis-uofu"
echo "::set-output name=docker_repo::lnis-uofu"
fi
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v1 uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx - name: Set up Docker Buildx
@ -16,7 +33,7 @@ jobs:
uses: docker/login-action@v1 uses: docker/login-action@v1
with: with:
registry: ghcr.io registry: ghcr.io
username: ${{ github.repository_owner }} username: ${{ needs.change_detect.outputs.docker_repo }}
password: ${{ secrets.CR_PAT }} password: ${{ secrets.CR_PAT }}
- name: Build base - name: Build base
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
@ -24,14 +41,14 @@ jobs:
context: . context: .
file: ./docker/Dockerfile.base file: ./docker/Dockerfile.base
push: true push: true
tags: ghcr.io/lnis-uofu/openfpga-build-base:latest tags: ghcr.io/${{ needs.change_detect.outputs.docker_repo }}/openfpga-build-base:latest
- name: Build environment image - name: Build environment image
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
with: with:
context: . context: .
file: ./docker/Dockerfile.env file: ./docker/Dockerfile.env
push: true push: true
tags: ghcr.io/lnis-uofu/openfpga-env:latest tags: ghcr.io/${{ needs.change_detect.outputs.docker_repo }}/openfpga-env:latest
compiler_images: compiler_images:
name: Build ${{ matrix.compiler }} compiler image name: Build ${{ matrix.compiler }} compiler image
needs: base_images needs: base_images
@ -57,7 +74,7 @@ jobs:
uses: docker/login-action@v1 uses: docker/login-action@v1
with: with:
registry: ghcr.io registry: ghcr.io
username: ${{ github.repository_owner }} username: ${{ needs.change_detect.outputs.docker_repo }}
password: ${{ secrets.CR_PAT }} password: ${{ secrets.CR_PAT }}
- name: Build ${{ matrix.compiler }} image - name: Build ${{ matrix.compiler }} image
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
@ -65,4 +82,4 @@ jobs:
context: . context: .
file: ./docker/Dockerfile.${{ matrix.compiler }} file: ./docker/Dockerfile.${{ matrix.compiler }}
push: true push: true
tags: ghcr.io/lnis-uofu/openfpga-build-${{ matrix.compiler }}:latest tags: ghcr.io/${{ needs.change_detect.outputs.docker_repo }}/openfpga-build-${{ matrix.compiler }}:latest