diff --git a/.github/workflows/tarrr_file.yml b/.github/workflows/tarrr_file.yml index a5b656b2781..d1f9b401f42 100644 --- a/.github/workflows/tarrr_file.yml +++ b/.github/workflows/tarrr_file.yml @@ -1,185 +1,207 @@ -name: Testt Build Final -env: - RELEASE: '2021.1' - PIPELINE: 'xrt' - ENV: 'test' - -on: - workflow_dispatch: - -jobs: - build: - strategy: - matrix: - include: - - os: centos8 - packageType: rpm - os_ver: centos_8.1 - # - os: ubuntu2004 - # packageType: deb - # os_ver: ubuntu_20.04 - # - os: ubuntu2204 - # packageType: deb - # os_ver: ubuntu_22.04 - # - os: amazonlinux-20202011111 - # packageType: rpm - # os_ver: amazonlinux20202011111 - # - os: ubuntu1804 - # packageType: deb - # os_ver: ubuntu_18.04 - +name: Test Build Final +env: + RELEASE: '2021.1' + PIPELINE: 'xrt' + ENV: 'test' + +on: + workflow_dispatch: + +jobs: + build: + strategy: + matrix: + include: + - os: centos8 + packageType: rpm + os_ver: centos_8.1 + # Uncomment the following lines to enable other OS builds + # - os: ubuntu2004 + # packageType: deb + # os_ver: ubuntu_20.04 + # - os: ubuntu2204 + # packageType: deb + # os_ver: ubuntu_22.04 + # - os: amazonlinux-20202011111 + # packageType: rpm + # os_ver: amazonlinux20202011111 + # - os: ubuntu1804 + # packageType: deb + # os_ver: ubuntu_18.04 + runs-on: [self-hosted, Ubuntu-22.04] - steps: - - name: Set env variables - run: | - echo "Setting environment variables..." - echo "XRT_VERSION_PATCH=$(($GITHUB_RUN_NUMBER+717))" >> $GITHUB_ENV - echo "PATH=/usr/bin:$PATH" >> $GITHUB_ENV - - - name: Checkout PR - uses: actions/checkout@v3 - with: + steps: + - name: Set env variables + run: | + echo "Setting environment variables..." + echo "XRT_VERSION_PATCH=$(($GITHUB_RUN_NUMBER+717))" >> $GITHUB_ENV + echo "PATH=/usr/bin:$PATH" >> $GITHUB_ENV + + - name: Checkout PR + uses: actions/checkout@v3 + with: ref: '2021.1' fetch-depth: 0 - path: ${{ github.workspace }}/${{ env.XRT_VERSION_PATCH }} - submodules: recursive + path: ${{ github.workspace }}/${{ env.XRT_VERSION_PATCH }} + submodules: recursive - name: Create directory for Dockerfile run: mkdir -p ${{ github.workspace }}/dockerfiles - - - name: Checkout Dockerfile from master - run: | - git init - if git remote | grep -q origin; then + + - name: Checkout Dockerfile from master + run: | + git init + if git remote | grep -q origin; then git remote remove origin - fi - git remote add origin https://github.com/Xilinx/preflight-check.git - git config core.sparseCheckout true - echo "Dockerfile" >> .git/info/sparse-checkout - git fetch origin master - git checkout master - working-directory: ${{ github.workspace }}/dockerfiles - - - name: Checkout private repository - uses: actions/checkout@v3 - with: + fi + git remote add origin https://github.com/Xilinx/preflight-check.git + git config core.sparseCheckout true + echo "Dockerfile" >> .git/info/sparse-checkout + git fetch origin master + git checkout master + working-directory: ${{ github.workspace }}/dockerfiles + + - name: Checkout private repository + uses: actions/checkout@v3 + with: repository: actions-int/composite-workflows - github-server-url: ${{ secrets.SERVER_URL }} - token: ${{ secrets.ACCESS_TOKEN }} - path: composite-workflows + github-server-url: ${{ secrets.SERVER_URL }} + token: ${{ secrets.ACCESS_TOKEN }} + path: composite-workflows ref: image - - - name: XRT build + + - name: XRT build uses: ./composite-workflows/build - with: - pipeline: ${{ env.PIPELINE }} - osVersion: ${{ matrix.os }} + with: + pipeline: ${{ env.PIPELINE }} + osVersion: ${{ matrix.os }} packageType: ${{ matrix.packageType }} - os_ver: ${{ matrix.os_ver }} + os_ver: ${{ matrix.os_ver }} workspace: ${{ github.workspace }} - buildNumber: ${{ env.XRT_VERSION_PATCH }} + buildNumber: ${{ env.XRT_VERSION_PATCH }} accessToken: ${{ secrets.ACCESS_TOKEN }} github-server-url: ${{ secrets.SERVER_URL }} - appConfig: ${{ secrets.APP_CONFIG }} - appConfig1: ${{ secrets.APP_CONFIG1 }} - appConfig2: ${{ secrets.APP_CONFIG2 }} - appConfig3: ${{ secrets.APP_CONFIG3 }} - + appConfig: ${{ secrets.APP_CONFIG }} + appConfig1: ${{ secrets.APP_CONFIG1 }} + appConfig2: ${{ secrets.APP_CONFIG2 }} + appConfig3: ${{ secrets.APP_CONFIG3 }} - package-download: - needs: [build] - runs-on: [self-hosted, Ubuntu-22.04] + package-download: + needs: [build] + runs-on: [self-hosted, Ubuntu-22.04] steps: - - name: Set env variables - run: | - echo "Setting environment variables..." - echo "XRT_VERSION_PATCH=$(($GITHUB_RUN_NUMBER+717))" >> $GITHUB_ENV - echo "PATH=/usr/bin:$PATH" >> $GITHUB_ENV - - name: Checkout private repository - uses: actions/checkout@v3 - with: - repository: actions-int/composite-workflows + - name: Set env variables + run: | + echo "Setting environment variables..." + echo "XRT_VERSION_PATCH=$(($GITHUB_RUN_NUMBER+717))" >> $GITHUB_ENV + echo "PATH=/usr/bin:$PATH" >> $GITHUB_ENV + + - name: Checkout private repository + uses: actions/checkout@v3 + with: + repository: actions-int/composite-workflows token: ${{ secrets.ACCESS_TOKEN }} - github-server-url: ${{ secrets.SERVER_URL }} - path: composite-workflows + github-server-url: ${{ secrets.SERVER_URL }} + path: composite-workflows ref: '2021.1' - - - name: Use composite action package download - uses: ./composite-workflows/package-download - with: - runNumber: ${{ env.XRT_VERSION_PATCH }} - pipeline: ${{ env.PIPELINE }} + - name: Use composite action package download + uses: ./composite-workflows/package-download + with: + runNumber: ${{ env.XRT_VERSION_PATCH }} + pipeline: ${{ env.PIPELINE }} env: ${{ env.ENV }} - release: ${{ env.RELEASE }} - sshKey: ${{ secrets.CI_PRIVATE_SSH_KEY }} + release: ${{ env.RELEASE }} + sshKey: ${{ secrets.CI_PRIVATE_SSH_KEY }} accessToken: ${{ secrets.ACCESS_TOKEN }} NPATH: ${{ secrets.NPATH }} USER: ${{ secrets.USER }} - github-server-url: ${{ secrets.SERVER_URL }} - - - name: List contents of artifact directory - run: | - cd ${{ env.PATH_DIR }}/artifact - ls -al - shell: bash - - - name: List contents of Dockerfile directory - run: | - echo "Contents of Dockerfile directory:" - ls -al ${{ github.workspace }}/dockerfiles/Dockerfile - shell: bash - - - name: Find and copy packages - run: | - cd ${{ env.PATH_DIR }}/artifact - echo "Listing all files in artifact directory:" - ls -al - for package_file in *-xrt.rpm *-xrt.deb; do - echo "Found package: $package_file" - cp $package_file ${{ github.workspace }}/dockerfiles/Dockerfile/ - done - shell: bash - - docker-build: - needs: [package-download] - runs-on: [self-hosted, Ubuntu-22.04] - steps: - - name: Set env variables - run: | - echo "Setting environment variables..." - echo "XRT_VERSION_PATCH=$(($GITHUB_RUN_NUMBER+717))" >> $GITHUB_ENV - echo "PATH=/usr/bin:$PATH" >> $GITHUB_ENV - - - name: List contents of Dockerfile directory - run: | - echo "Contents of Dockerfile directory:" - ls -al ${{ github.workspace }}/dockerfiles/Dockerfile - shell: bash - - - name: Build Docker images - run: | - for package_file in ${{ github.workspace }}/dockerfiles/Dockerfile/*-xrt.rpm ${{ github.workspace }}/dockerfiles/Dockerfile/*-xrt.deb; do - echo "Building image for $package_file" - image_tag=$(basename $package_file | sed 's/\.[^.]*$//') - if [[ $package_file == *centos_8.1* ]]; then - base_image="centos:8" - elif [[ $package_file == *ubuntu_20.04* ]]; then - base_image="ubuntu:20.04" - elif [[ $package_file == *ubuntu_22.04* ]]; then - base_image="ubuntu:22.04" - elif [[ $package_file == *amazonlinux20202011111* ]]; then - base_image="amazonlinux:2" - else - base_image="ubuntu:18.04" - fi - docker build --build-arg PACKAGE_FILE=$(basename $package_file) --build-arg BASE_IMAGE=$base_image -t xrt_image:$image_tag -f ${{ github.workspace }}/dockerfiles/Dockerfile/Dockerfile ${{ github.workspace }}/dockerfiles/Dockerfile - done - shell: bash - + github-server-url: ${{ secrets.SERVER_URL }} + + - name: List contents of artifact directory + run: | + cd ${{ env.PATH_DIR }}/artifact + ls -al + shell: bash + + - name: List contents of Dockerfile directory + run: | + echo "Contents of Dockerfile directory:" + ls -al ${{ github.workspace }}/dockerfiles/Dockerfile + shell: bash + + - name: Find and copy packages + run: | + cd ${{ env.PATH_DIR }}/artifact + echo "Listing all files in artifact directory:" + ls -al + for package_file in *-xrt.rpm; do + echo "Found package: $package_file" + cp $package_file ${{ github.workspace }}/dockerfiles/Dockerfile/ + done + # Uncomment the following lines to handle .deb packages + # if ls *-xrt.deb 1> /dev/null 2>&1; then + # for package_file in *-xrt.deb; do + # echo "Found package: $package_file" + # cp $package_file ${{ github.workspace }}/dockerfiles/Dockerfile/ + # done + # else + # echo "No .deb packages found." + # fi + shell: bash + + docker-build: + needs: [package-download] + runs-on: [self-hosted, Ubuntu-22.04] + steps: + - name: Set env variables + run: | + echo "Setting environment variables..." + echo "XRT_VERSION_PATCH=$(($GITHUB_RUN_NUMBER+717))" >> $GITHUB_ENV + echo "PATH=/usr/bin:$PATH" >> $GITHUB_ENV + + - name: List contents of Dockerfile directory + run: | + echo "Contents of Dockerfile directory:" + ls -al ${{ github.workspace }}/dockerfiles/Dockerfile + shell: bash + + - name: Build Docker images + run: | + for package_file in ${{ github.workspace }}/dockerfiles/Dockerfile/*-xrt.rpm; do + echo "Building image for $package_file" + image_tag=$(basename $package_file | sed 's/\.[^.]*$//') + if [[ $package_file == *centos_8.1* ]]; then + base_image="centos:8" + elif [[ $package_file == *ubuntu_20.04* ]]; then + base_image="ubuntu:20.04" + elif [[ $package_file == *ubuntu_22.04* ]]; then + base_image="ubuntu:22.04" + elif [[ $package_file == *amazonlinux20202011111* ]]; then + base_image="amazonlinux:2" + else + base_image="ubuntu:18.04" + fi + docker build --build-arg PACKAGE_FILE=$(basename $package_file) --build-arg BASE_IMAGE=$base_image -t xrt_image:$image_tag -f ${{ github.workspace }}/dockerfiles/Dockerfile/Dockerfile ${{ github.workspace }}/dockerfiles/Dockerfile + done + # Uncomment the following lines to handle .deb packages + # for package_file in ${{ github.workspace }}/dockerfiles/Dockerfile/*-xrt.deb; do + # echo "Building image for $package_file" + # image_tag=$(basename $package_file | sed 's/\.[^.]*$//') + # if [[ $package_file == *ubuntu_20.04* ]]; then + # base_image="ubuntu:20.04" + # elif [[ $package_file == *ubuntu_22.04* ]]; then + # base_image="ubuntu:22.04" + # elif [[ $package_file == *ubuntu_18.04* ]]; then + # base_image="ubuntu:18.04" + # fi + # docker build --build-arg PACKAGE_FILE=$(basename $package_file) --build-arg BASE_IMAGE=$base_image -t xrt_image:$image_tag -f ${{ github.workspace }}/dockerfiles/Dockerfile/Dockerfile ${{ github.workspace }}/dockerfiles/Dockerfile + # done + shell: bash + - name: Verify XRT package in Docker image run: | - for package_file in ${{ github.workspace }}/dockerfiles/Dockerfile/*-xrt.rpm ${{ github.workspace }}/dockerfiles/Dockerfile/*-xrt.deb; do + for package_file in ${{ github.workspace }}/dockerfiles/Dockerfile/*-xrt.rpm; do image_tag=$(basename $package_file | sed 's/\.[^.]*$//') echo "Running container from image xrt_image:$image_tag" docker run --rm xrt_image:$image_tag bash -c " @@ -190,20 +212,34 @@ jobs: fi " done - shell: bash - - - - name: Authenticate with Harbor - run: | - echo "${{ secrets.HARBOR_PASSWORD }}" | docker login registry.amd.com -u '${{ secrets.HARBOR_USERNAME }}' --password-stdin - shell: bash - - - name: Push Docker images to AMD Harbor - run: | - for package_file in ${{ github.workspace }}/dockerfiles/Dockerfile/*-xrt.rpm ${{ github.workspace }}/dockerfiles/Dockerfile/*-xrt.deb; do - image_tag=$(basename $package_file | sed 's/\.[^.]*$//') - echo "Pushing image xrt_image:$image_tag" - docker tag xrt_image:$image_tag registry.amd.com/buildops/xrt_image:$image_tag - docker push registry.amd.com/buildops/xrt_image:$image_tag - done - shell: bash + # Uncomment the following lines to verify .deb packages + # for package_file in ${{ github.workspace }}/dockerfiles/Dockerfile/*-xrt.deb; do + # image_tag=$(basename $package_file | sed 's/\.[^.]*$//') + # echo "Running container from image xrt_image:$image_tag" + # docker run --rm xrt_image:$image_tag bash -c " + # dpkg -l | grep xrt + # " + # done + shell: bash + + - name: Authenticate with Harbor + run: | + echo "${{ secrets.HARBOR_PASSWORD }}" | docker login registry.amd.com -u '${{ secrets.HARBOR_USERNAME }}' --password-stdin + shell: bash + + - name: Push Docker images to AMD Harbor + run: | + for package_file in ${{ github.workspace }}/dockerfiles/Dockerfile/*-xrt.rpm; do + image_tag=$(basename $package_file | sed 's/\.[^.]*$//') + echo "Pushing image xrt_image:$image_tag" + docker tag xrt_image:$image_tag registry.amd.com/buildops/xrt_image:$image_tag + docker push registry.amd.com/buildops/xrt_image:$image_tag + done + # Uncomment the following lines to push .deb images + # for package_file in ${{ github.workspace }}/dockerfiles/Dockerfile/*-xrt.deb; do + # image_tag=$(basename $package_file | sed 's/\.[^.]*$//') + # echo "Pushing image xrt_image:$image_tag" + # docker tag xrt_image:$image_tag registry.amd.com/buildops/xrt_image:$image_tag + # docker push registry.amd.com/buildops/xrt_image:$image_tag + # done + shell: bash