Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable release image building #104

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 42 additions & 2 deletions .github/workflows/image-c-cpp_tmpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,34 @@ on:
ninja_build:
required: true
type: boolean
test:
required: true
type: boolean
install:
required: true
type: boolean
secrets:
CMAIZE_GITHUB_TOKEN:
required: true
CONTAINER_REPO_TOKEN:
required: true

jobs:
Repo_name_lowcase:
runs-on: ubuntu-latest
outputs:
lowcase_repo_name: ${{ steps.output-repo-name.outputs.repo_name }}
steps:
- name: Output repo name in lowcase
id: output-repo-name
run: |
name=${{ inputs.repo }}
echo "repo_name=${name,,}" >> "$GITHUB_OUTPUT"
Build:
runs-on: ubuntu-latest
needs: Repo_name_lowcase
container:
# will make the image choosing automatical later. Now it is hardwired
image: ghcr.io/nwchemex-project/build_parallelzone:v1
image: ghcr.io/nwchemex-project/build_${{needs.Repo_name_lowcase.outputs.lowcase_repo_name}}:v1
credentials:
username: ${{ github.actor }}
password: ${{ secrets.CONTAINER_REPO_TOKEN }}
Expand All @@ -44,6 +60,7 @@ jobs:
uses: NWChemEx-Project/.github/actions/image-build@master
with:
CMAIZE_GITHUB_TOKEN: ${{ secrets.CMAIZE_GITHUB_TOKEN }}
INSTALL: ${{ inputs.install }}
- name: Build using GCC
if: ${{inputs.gcc-build == true}}
env:
Expand All @@ -53,7 +70,30 @@ jobs:
uses: NWChemEx-Project/.github/actions/image-build@master
with:
CMAIZE_GITHUB_TOKEN: ${{ secrets.CMAIZE_GITHUB_TOKEN }}
INSTALL: ${{ inputs.install }}
- name: Test Application
if: ${{inputs.test == true}}
uses: NWChemEx-Project/.github/actions/image-test@master
with:
CMAIZE_GITHUB_TOKEN: ${{ secrets.CMAIZE_GITHUB_TOKEN }}
- name: Login to GitHub Container Registry
if: ${{inputs.gcc-build == true}} && ${{inputs.install == true}}
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.CONTAINER_REPO_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
if: ${{inputs.gcc-build == true}} && ${{inputs.install == true}}
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ghcr.io/nwchemex-project/release_${{needs.Repo_name_lowcase.outputs.lowcase_repo_name}}
- name: Build the image and push
if: ${{inputs.gcc-build == true}} && ${{inputs.install == true}}
uses: docker/build-push-action@v4
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this going to push every time this workflow is run? Isn't this also the workflow used for testing the PRs? We don't want those to be the same workflow as the deployment is different than the testing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this going to push every time this workflow is run? Isn't this also the workflow used for testing the PRs? We don't want those to be the same workflow as the deployment is different than the testing.

So you mean a separated workflow simply to deploy the code, right? What would be the event to trigger this workflow, say a successful testing?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Here's some sketches meant to depict how I'm thinking about the various use cases. The sketch shows the DockerFiles living in the respective repos. If you're able to create a single DockerFile which can be used to build each repo's base image (presumably by using variables for the the base image's base image and the dependencies to build) and/or a single DockerFile for building the release images (presumably by using variables for the base image) then those common DockerFiles can live here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this going to push every time this workflow is run? Isn't this also the workflow used for testing the PRs? We don't want those to be the same workflow as the deployment is different than the testing.

Added options to install the package, build and push the release docker image only when necessary. Different calls would come from different workflow in the corresponding repo invoked by different events, e. g., PR or push to master.

with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
3 changes: 3 additions & 0 deletions actions/image-build/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: Build with Docker Image
inputs:
CMAIZE_GITHUB_TOKEN:
required: true
INSTALL:
required: true

runs:
using: "composite"
Expand All @@ -12,5 +14,6 @@ runs:
- name: Build Application
env:
CMAIZE_GITHUB_TOKEN: ${{inputs.CMAIZE_GITHUB_TOKEN}}
INSTALL: ${{ inputs.INSTALL }}
run: ${GITHUB_ACTION_PATH}/build.sh
shell: bash
21 changes: 17 additions & 4 deletions actions/image-build/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,25 @@ else
fi

#Step 2: Configure

if [ "${ninja_build}" = true ] ; then
${cmake_command} -GNinja -H. -Bbuild -DCMAKE_TOOLCHAIN_FILE="${toolchain_file}"
if [ "${INSTALL}" = true ]; then
export INSTALL_PATH=install
if [ "${ninja_build}" = true ] ; then
${cmake_command} -GNinja -H. -Bbuild -DCMAKE_TOOLCHAIN_FILE="${toolchain_file}" -DCMAKE_INSTALL_PREFIX=${INSTALL_PATH}
else
${cmake_command} -H. -Bbuild -DCMAKE_TOOLCHAIN_FILE="${toolchain_file}" -DCMAKE_INSTALL_PREFIX=${INSTALL_PATH}
fi
else
${cmake_command} -H. -Bbuild -DCMAKE_TOOLCHAIN_FILE="${toolchain_file}"
if [ "${ninja_build}" = true ] ; then
${cmake_command} -GNinja -H. -Bbuild -DCMAKE_TOOLCHAIN_FILE="${toolchain_file}"
else
${cmake_command} -H. -Bbuild -DCMAKE_TOOLCHAIN_FILE="${toolchain_file}"
fi
fi

#Step 3: Compile
${cmake_command} --build build

#Step 4: Install
if [ "${INSTALL}" = true ]; then
${cmake_command} --build build --target install
fi