Skip to content

Added skip_matrix_jobs option to create-packages #2

Added skip_matrix_jobs option to create-packages

Added skip_matrix_jobs option to create-packages #2

Workflow file for this run

name: Create package
on:
workflow_call:
inputs:
skip_checks:
description: Value `true` will skip version checks, use for testing or in nightly builds.
type: boolean
required: false
cpack_options:
description: CPack options to be used on all platforms.
type: string
required: false
cpack_options_deb:
description: CPack options for DEB generator
type: string
required: false
cpack_options_rpm:
description: CPack options for RPM generator
type: string
required: false
skip_matrix_jobs:
description: list of matrix jobs to skip
type: string
required: false
secrets:
url_debian_11:
description: Use other than the default url for Debian 11.
required: false
token_debian_11:
description: Use other than the default token for Debian 11.
required: false
url_centos_7:
description: Use other than the default url for CentOS 7.
required: false
token_centos_7:
description: Use other than the default token for CentOS 7.
required: false
url_rocky_8:
description: Use other than the default url for Rocky 8.
required: false
token_rocky_8:
description: Use other than the default token for Rocky 8.
required: false
jobs:
deploy:
if: ${{ github.ref_type == 'tag' || inputs.skip_checks }}
strategy:

Check failure on line 49 in .github/workflows/create-package.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/create-package.yml

Invalid workflow file

You have an error in your yaml syntax on line 49
fail-fast: false
matrix:
name:
- gnu@debian-11
# centos 7 is not compatible with node20
# - [email protected]
- [email protected]
include:
- name: gnu@debian-11
labels: [self-hosted, platform-builder-debian-11]
os: debian-11
compiler: gnu
compiler_cc: gcc
compiler_cxx: g++
compiler_fc: gfortran
cpack_generator: DEB
cpack_options: >
-D [email protected]
-D CPACK_PACKAGING_INSTALL_PREFIX=/opt/ecmwf
${{ inputs.cpack_options_deb }}
-DCPACK_DEBIAN_PACKAGE_SHLIBDEPS=ON
upload_token: NEXUS_TEST_REPO_UPLOAD_TOKEN
upload_url: NEXUS_TEST_REPO_URL_DEBIAN_11
# - name: [email protected]
# labels: [self-hosted, platform-builder-centos-7.9]
# os: centos-7.9
# compiler: gnu-8
# compiler_cc: gcc-8
# compiler_cxx: g++-8
# compiler_fc: gfortran-8
# cpack_generator: RPM
# cpack_options: >
# -D CPACK_PACKAGING_INSTALL_PREFIX=/opt/ecmwf
# ${{ inputs.cpack_options_rpm }}
# upload_token: NEXUS_TEST_REPO_UPLOAD_TOKEN
# upload_url: NEXUS_TEST_REPO_URL_CENTOS_7
- name: [email protected]
labels: [self-hosted, platform-builder-rocky-8.6]
os: rocky-8.6
compiler: gnu
compiler_cc: gcc
compiler_cxx: g++
compiler_fc: gfortran
cpack_generator: RPM
cpack_options: >
-D CPACK_PACKAGING_INSTALL_PREFIX=/opt/ecmwf
${{ inputs.cpack_options_rpm }}
upload_token: NEXUS_TEST_REPO_UPLOAD_TOKEN
upload_url: NEXUS_TEST_REPO_URL_ROCKY_8
exclude: ${{ inputs.skip_matrix_jobs }}
runs-on: ${{ matrix.labels }}
steps:
- uses: actions/checkout@v3
- name: Check version number
if: ${{ !inputs.skip_checks }}
shell: python3 {0}
run: |
import os
import re
import sys
tag = "${{ github.ref_name }}"
def check_version():
file_name = "VERSION"
if os.path.isfile(file_name):
with open(file_name, 'r') as f:
version = f.read().strip()
return version
else:
print(f"::warning::{file_name} file not found! Using {file_name} is the preferred method.")
return
def check_cmakelists():
file_name = "CMakeLists.txt"
if os.path.isfile(file_name):
with open(file_name, 'r') as f:
content = f.read()
pattern = r"project\([\s\w]+VERSION\s+((?:\d+)(?:.\d+){0,3})"
hit = re.search(pattern, content)
version = hit.group(1)
return version
else:
print(f"::warning::{file_name} file not found!")
return
version = check_version() or check_cmakelists()
if not version:
print("::error::Version not found!")
sys.exit(1)
if version != tag:
print(f"::error::Git tag ({tag}) and project version ({version}) do not match!")
sys.exit(1)
print("OK: Git tag and project versions match.")
- name: Create package
id: build
uses: ecmwf-actions/reusable-workflows/build-package-with-config@v2
with:
repository: ${{ format('{0}@{1}', github.repository, github.sha ) }}
build_package_inputs: |
repository: ${{ format('{0}@{1}', github.repository, github.sha ) }}
cpack_generator: ${{ matrix.cpack_generator }}
cpack_options: ${{ matrix.cpack_options }} ${{ inputs.cpack_options }}
force_build: true
recreate_cache: true
save_cache: false
self_test: false
build_config: .github/ci-config.yml
- name: Upload binary as artifact
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.os }}
path: ${{ steps.build.outputs.package_path }}
retention-days: 3
- name: Upload
run: |
if [ -z "${{ steps.build.outputs.package_path }}" ] || [ ! -f ${{ steps.build.outputs.package_path }} ]; then
echo "::error::Built package not found!"
exit 1
fi
os=${{ matrix.os }}
token=""
url=""
case "$os" in
"debian-11")
token=${{ secrets.token_debian_11 || secrets[matrix.upload_token] }}
url=${{ secrets.url_debian_11 || secrets[matrix.upload_url] }}
;;
"centos-7.9")
token=${{ secrets.token_centos_7 || secrets[matrix.upload_token] }}
url=${{ secrets.url_centos_7 || secrets[matrix.upload_url] }}
;;
"rocky-8.6")
token=${{ secrets.token_rocky_8 || secrets[matrix.upload_token] }}
url=${{ secrets.url_rocky_8 || secrets[matrix.upload_url] }}
;;
*)
token=${{ secrets[matrix.upload_token] }}
url=${{ secrets[matrix.upload_url] }}
;;
esac
if [ "${{ matrix.cpack_generator }}" == "DEB" ]; then
response=$(curl -w "%{http_code}" --user "$token" -H "Content-Type: multipart/form-data" --data-binary "@${{ steps.build.outputs.package_path }}" "$url")
elif [ "${{ matrix.cpack_generator }}" == "RPM" ]; then
file_name=$(basename "${{ steps.build.outputs.package_path }}")
response=$(curl -w "%{http_code}" --user "$token" --upload-file ${{ steps.build.outputs.package_path }} $url/$file_name)
fi
status=$(echo $response | tail -c 4)
if [ $status -eq 201 ] || [ $status -eq 200 ]; then
echo "Successfully uploaded!"
else
echo "$status: Upload failed"
exit 1
fi