Skip to content

Commit

Permalink
[CI:BUILD] followup PR for fcos with podman-next
Browse files Browse the repository at this point in the history
Followup on containers#19477

[NO NEW TESTS NEEDED]

Signed-off-by: Lokesh Mandvekar <[email protected]>
  • Loading branch information
lsm5 committed Sep 7, 2023
1 parent 0c72726 commit 898e6ca
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 36 deletions.
17 changes: 0 additions & 17 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -930,22 +930,6 @@ upgrade_test_task:
always: *logs_artifacts


#fcos_image_build_task:
# Only a test. Does not push built images.
# Image push to quay will be handled by GHA in
# .github/workflows/fcos-podman-next-build.yml
#name: "Test Build FCOS image $CTXDIR"
#alias: fcos_image_build
#only_if: $CIRRUS_PR != '' && $CIRRUS_BASE_BRANCH == 'main' && $CIRRUS_CHANGE_TITLE !=~ '.*CI:DOCS.*'
#env:
# <<: *stdenvars
# CTXDIR: contrib/podman-next/fcos-podmanimage
# TEST_FLAVOR: "fcos_image_build"
#gce_instance: *standardvm
#setup_script: *setup
#main_script: *main


# This task is critical. It updates the "last-used by" timestamp stored
# in metadata for all VM images. This mechanism functions in tandem with
# an out-of-band pruning operation to remove disused VM images.
Expand Down Expand Up @@ -1017,7 +1001,6 @@ success_task:
- buildah_bud_test
- rootless_buildah_bud_test
- upgrade_test
#- fcos_image_build
- meta
container: &smallcontainer
image: ${CTR_FQIN}
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/fcos-podman-next-build-prepush-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Build FCOS image with rhcontainerbot/podman-next

on:
pull_request:
branches:
- main

env:
IMAGE_NAME: fcos
IMAGE_REGISTRY: quay.io/podman
COPR_OWNER: rhcontainerbot
COPR_PROJECT: podman-next

jobs:
fcos-podman-next-image-build-prepush-test:
runs-on: ubuntu-latest

steps:
- name: Check out code
uses: actions/checkout@v4

- name: Build FCOS Image
id: build_image_test
# Ref: https://github.com/redhat-actions/buildah-build
uses: redhat-actions/buildah-build@v2
with:
image: ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}
tags: ${{ github.sha }}
containerfiles: ./contrib/podman-next/fcos-podmanimage/Containerfile
56 changes: 45 additions & 11 deletions .github/workflows/fcos-podman-next-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ on:

env:
IMAGE_NAME: fcos
IMAGE_TAGS: latest next podman-next ${{ github.sha }}
# IMAGE_ARCHS has to be comma separated
IMAGE_ARCHS: amd64, arm64
IMAGE_REGISTRY: quay.io/podman
COPR_OWNER: rhcontainerbot
COPR_PROJECT: podman-next
Expand All @@ -17,36 +18,69 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Install qemu dependency
run: |
sudo apt update
sudo apt -y install qemu-user-static
- name: Set up wait-for-copr
run: |
pip3 install git+https://github.com/packit/wait-for-copr.git@main
- name: Check out code
uses: actions/checkout@v4

- name: Get short SHA from HEAD
run: echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> "$GITHUB_ENV"
id: short_sha

- name: Wait for successful podman-next build with the latest commit
run: |
# TODO: add this in the Containerfile itself or as a --build-arg
wait-for-copr --owner ${{ env.COPR_OWNER }} --project ${{ env.COPR_PROJECT }} podman $(git rev-parse --short ${{ github.sha }})
wait-for-copr --owner ${{ env.COPR_OWNER }} --project ${{ env.COPR_PROJECT }} podman $SHORT_SHA
echo "podman-next build successful."
- name: Check out code
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4

- name: Build FCOS Image
id: build_image
id: build_image_multiarch
# Ref: https://github.com/redhat-actions/buildah-build
uses: redhat-actions/buildah-build@v2
with:
image: ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}
tags: ${{env.IMAGE_TAGS }}
containerfiles: |
./contrib/podman-next/fcos-podmanimage/Containerfile .
# COPR_PROJECT envvar is used for the podman-next floating tag
tags: ${{ env.COPR_PROJECT }} ${{ github.sha }} $SHORT_SHA
archs: ${{ env.IMAGE_ARCHS }}
containerfiles: ./contrib/podman-next/fcos-podmanimage/Containerfile

- name: Echo Outputs
run: |
echo "Image: ${{ steps.build_image_multiarch.outputs.image }}"
echo "Tags: ${{ steps.build_image_multiarch.outputs.tags }}"
echo "Tagged Image: ${{ steps.build_image_multiarch.outputs.image-with-tag }}"
- name: Check images created
run: buildah images | grep '${{ env.IMAGE_NAME }}'

- name: Check image metadata
run: |
set -x
# COPR_PROJECT envvar is used for the `podman-next` floating tag
buildah inspect ${{ steps.build_image_multiarch.outputs.image }}:${{ env.COPR_PROJECT }} | jq ".OCIv1.architecture"
buildah inspect ${{ steps.build_image_multiarch.outputs.image }}:${{ env.COPR_PROJECT }} | jq ".Docker.architecture"
buildah inspect ${{ steps.build_image_multiarch.outputs.image }}:${{ github.sha }} | jq ".OCIv1.architecture"
buildah inspect ${{ steps.build_image_multiarch.outputs.image }}:${{ github.sha }} | jq ".Docker.architecture"
buildah inspect ${{ steps.build_image_multiarch.outputs.image }}:$SHORT_SHA | jq ".OCIv1.architecture"
buildah inspect ${{ steps.build_image_multiarch.outputs.image }}:$SHORT_SHA | jq ".Docker.architecture"
- name: Run image
run: podman run --rm ${{ steps.build_image_multiarch.outputs.image-with-tag }}

- name: Push to Quay
id: push-to-quay
# Ref: https://github.com/redhat-actions/push-to-registry
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build-image.outputs.image }}
tags: ${{ steps.build-image.outputs.tags }}
image: ${{ env.IMAGE_NAME }}
tags: ${{ steps.build_image_multiarch.outputs.tags }}
registry: ${{ env.IMAGE_REGISTRY }}
username: ${{ secrets.QUAY_PODMAN_USERNAME }}
password: ${{ secrets.QUAY_PODMAN_PASSWORD }}
6 changes: 6 additions & 0 deletions .packit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ PACKAGE=podman
# Set path to rpm spec file
SPEC_FILE=rpm/$PACKAGE.spec

# Get short sha
SHORT_SHA=$(git rev-parse --short HEAD)

# Get Version from HEAD
VERSION=$(grep '^const RawVersion' version/rawversion/version.go | cut -d\" -f2)

Expand All @@ -36,3 +39,6 @@ sed -i "s/^Source0:.*.tar.gz/Source0: $PACKAGE-$VERSION.tar.gz/" $SPEC_FILE

# Update setup macro to use the correct build dir
sed -i "s/^%autosetup.*/%autosetup -Sgit -n %{name}-$VERSION/" $SPEC_FILE

# podman --version should show short sha
sed -i "/^$VERSION/$VERSION-$SHORT_SHA/" version/rawversion/version.go
6 changes: 0 additions & 6 deletions contrib/cirrus/runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -338,12 +338,6 @@ function _run_gitlab() {
return $ret
}

# TODO: enable fcos_image_build task in cirrus
#function _run_fcos_image_build() {
# # FIXME: Doesn't seem to grab CTXDIR from .cirrus.yml
# CTXDIR="contrib/podman-next/fcos-podmanimage"
# podman build -t quay.io/podman/fcos:podman-next $CTXDIR
#}

# Name pattern for logformatter output file, derived from environment
function output_name() {
Expand Down
2 changes: 0 additions & 2 deletions contrib/cirrus/setup_environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,6 @@ case "$TEST_FLAVOR" in
swagger)
make .install.swagger
;;
#fcos_image_build)
# ;;
release) ;;
*) die_unknown TEST_FLAVOR
esac
Expand Down

0 comments on commit 898e6ca

Please sign in to comment.