Skip to content

Commit

Permalink
Opmtimized workflow to run tests in future dates
Browse files Browse the repository at this point in the history
  • Loading branch information
maxirmx committed Jan 24, 2024
1 parent 692dc73 commit 5a03578
Showing 1 changed file with 125 additions and 15 deletions.
140 changes: 125 additions & 15 deletions .github/workflows/time-machine.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,58 @@
name: centos-and-fedora
# Copyright (c) 2024 Ribose Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

name: time-machine
on:
push:
branches:
- main
- maxirmx-timemachine-2183
paths-ignore:
- '/*.sh'
- '/.*'
- '/_*'
- 'Brewfile'
- 'docs/**'
- '**.adoc'
- '**.md'
- '**.nix'
- 'flake.lock'
- '.github/workflows/*.yml'
- '!.github/workflows/time-machine.yml'
pull_request:
paths-ignore:
- '/*.sh'
- '/.*'
- '/_*'
- 'Brewfile'
- 'docs/**'
- '**.adoc'
- '**.md'
- '**.nix'
- 'flake.lock'
- '.github/workflows/*.yml'
- '!.github/workflows/time-machine.yml'
workflow_dispatch:
schedule:
- cron: "03 15 * * 6"

concurrency:
group: '${{ github.workflow }}-${{ github.job }}-${{ github.head_ref || github.ref_name }}'
Expand All @@ -16,8 +62,8 @@ env:
RNP_LOG_CONSOLE: 1

jobs:
tests:
name: ${{ matrix.image.name }} [CC ${{ matrix.env.CC }}; backend ${{ matrix.image.backend }} ]
build:
name: ${{ matrix.image.name }} [CC ${{ matrix.env.CC }}; backend ${{ matrix.image.backend }}]
runs-on: ubuntu-latest
timeout-minutes: 120
strategy:
Expand All @@ -26,14 +72,12 @@ jobs:
env:
- { CC: clang, CXX: clang++ }

# This workflow keeps all capabilities from the base one (centos-and-fedora.yml)
# but uses just few of tehm
# Pls refer to https://github.com/rnpgp/rnp-ci-containers#readme for image details
image:
- { name: 'Fedora 36', container: 'fedora-36-amd64', backend: 'Botan' }
- { name: 'Fedora 36', container: 'fedora-36-amd64', backend: 'OpenSSL' }
date-offset:
- '0 years'
- '1 year'
- '5 years'

container: ghcr.io/rnpgp/ci-rnp-${{ matrix.image.container }}

Expand Down Expand Up @@ -69,18 +113,84 @@ jobs:
- name: Build
run: cmake --build build --parallel ${{ env.CORES }}

- name: Install libfaketime
- name: Archive build files
run: tar -czvf build.tar.gz build

- name: Upload build files
uses: actions/upload-artifact@v3
with:
name: 'build-${{ matrix.env.CC }}-${{ matrix.image.backend }}'
path: 'build.tar.gz'
retention-days: 5

test:
name: ${{ matrix.image.name }} [CC ${{ matrix.env.CC }}; backend ${{ matrix.image.backend }}; date offset ${{ matrix.date-offset }}]
runs-on: ubuntu-latest
needs: build
timeout-minutes: 120
strategy:
fail-fast: false
matrix:
env:
- { CC: clang, CXX: clang++ }

# Pls refer to https://github.com/rnpgp/rnp-ci-containers#readme for image details
image:
- { name: 'Fedora 36', container: 'fedora-36-amd64', backend: 'Botan' }
- { name: 'Fedora 36', container: 'fedora-36-amd64', backend: 'OpenSSL' }

date-offset:
- '0 years'
- '1 year'
- '5 years'

container: ghcr.io/rnpgp/ci-rnp-${{ matrix.image.container }}

env: ${{ matrix.env }}
steps:
- name: Install tools
run: dnf -y install libfaketime

- name: Test
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true

- name: Setup environment
run: |
set -o errexit -o pipefail -o noclobber -o nounset
/opt/tools/tools.sh select_crypto_backend_for_gha ${{ matrix.image.backend }}
/opt/tools/tools.sh select_gpg_version_for_gha 'system'
/opt/tools/tools.sh select_botan_version_for_gha 'system'
echo CORES="$(nproc --all)" >> $GITHUB_ENV
useradd rnpuser
printf "\nrnpuser\tALL=(ALL)\tNOPASSWD:\tALL" > /etc/sudoers.d/rnpuser
printf "\nrnpuser\tsoft\tnproc\tunlimited\n" > /etc/security/limits.d/30-rnpuser.conf
- name: Download build files
uses: actions/download-artifact@v3
with:
name: 'build-${{ matrix.env.CC }}-${{ matrix.image.backend }}'

- name: Extract build files
run: tar -xzvf build.tar.gz

- name: Configure fake time
if: matrix.date-offset != '0 years'
run: |
set -o errexit -o pipefail -o noclobber -o nounset
adjusted_date=$(date -d '${{ matrix.date-offset }}' '+%Y-%m-%d')
export FAKETIME="@$adjusted_date 00:00:00"
test_adjusted_date=$(LD_PRELOAD=/usr/lib64/faketime/libfaketime.so.1 date '+%Y-%m-%d')
echo Running tests for "$test_adjusted_date"
echo FAKETIME="@$adjusted_date 00:00:00" >> $GITHUB_ENV
- name: Test
run: |
set -o errexit -o pipefail -o noclobber -o nounset
mkdir -p "build/Testing/Temporary"
cp "cmake/CTestCostData.txt" "build/Testing/Temporary"
export PATH="$PWD/build/src/lib:$PATH"
chown -R rnpuser:rnpuser $PWD
echo Running tests for "$(LD_PRELOAD=/usr/lib64/faketime/libfaketime.so.1 date)"
exec su rnpuser -c "LD_PRELOAD=/usr/lib64/faketime/libfaketime.so.1 ctest --parallel ${{ env.CORES }} --test-dir build --output-on-failure"

0 comments on commit 5a03578

Please sign in to comment.