Skip to content

test(github-actions): migrate tests to GitHub Actions #145

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

Merged
merged 41 commits into from
Dec 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
5c15684
test(github-actions): migrate tests to GitHub Actions
parfeon Nov 29, 2022
fc732d5
fix(github-actions): fix missing 'uses' in step
parfeon Nov 29, 2022
ad118dc
fix(github-actions): fix missing 'uses' in step
parfeon Nov 29, 2022
b7b4c32
fix(github-action): remove `runner` from concurrency setup
parfeon Nov 29, 2022
9d53576
fix(github-actions): fix typo in matrix
parfeon Nov 29, 2022
5a6ed69
fix(github-actions): add 'CXX' environment variable
parfeon Nov 30, 2022
70149fc
refactor(github-actions): add 'gcov' install to prepare step
parfeon Nov 30, 2022
55de4f7
fix(github-actions): fix values used in condition
parfeon Nov 30, 2022
1de213b
refactor(github-actions): specify CC and CXX as flags
parfeon Nov 30, 2022
a9c4a30
refactor(github-actions): lower 'cgreen' library version requirement
parfeon Nov 30, 2022
0e35f51
refactor(github-actions): install libm for ubuntu
parfeon Nov 30, 2022
c3e8b05
fix(github-actions): use sudo with apn-get and gem
parfeon Nov 30, 2022
fd50f86
refactor(github-actions): link libm
parfeon Nov 30, 2022
11d4640
test(github-actions): try to use reusable workflows
parfeon Nov 30, 2022
645270f
test(github-actions): fix reusable workflows location
parfeon Nov 30, 2022
921cff7
test(github-actions): fix reusable workflow configuration
parfeon Nov 30, 2022
89b6dee
test(github-actions): fix branch names for reusable workflow load
parfeon Nov 30, 2022
7b0bda8
test(github-actions): fix cache identifier and dependency
parfeon Nov 30, 2022
c872afb
test(github-actions): change names for reusable workflows
parfeon Nov 30, 2022
ca8e879
test(github-actions): fix names for reusable workflows
parfeon Nov 30, 2022
de01839
test(github-actions): fix gcov configuration
parfeon Nov 30, 2022
d28ca60
test(github-action): remove gcov usage
parfeon Nov 30, 2022
0d5b7c4
test(github-action): fix 'runs-on' for 'tests' job
parfeon Nov 30, 2022
0ca44e7
test(github-actions): swap order of steps in test
parfeon Nov 30, 2022
2642f48
refactor(github-actions): tests runner as local actions
parfeon Dec 1, 2022
9abdf0a
fix(github-actions): remove redundant 'secrets' field from job top level
parfeon Dec 1, 2022
823dcfc
fix(github-actions): fix paths to local actions
parfeon Dec 1, 2022
fae5252
fix(github-actions): fix YML syntax
parfeon Dec 1, 2022
5ae7f4d
fix(github-actions): return missing clone step
parfeon Dec 1, 2022
4d6a5e4
debug(github-actions): added directories content output
parfeon Dec 1, 2022
b105c8d
fix(github-actions): bash script folder copy path
parfeon Dec 1, 2022
b7a5ed2
debug(github-actions): added directories content output
parfeon Dec 1, 2022
70a477b
debug(github-actions): added directories content output
parfeon Dec 1, 2022
5f29d91
debug(github-actions): remove debug information
parfeon Dec 1, 2022
6303c95
fix(build): fix 'rm' calls with 'find' in 'clean' target
parfeon Dec 1, 2022
fbea70d
fix(github-actions): pass secrets properly to composite action
parfeon Dec 2, 2022
f37e6d3
refactor(github-actions): move code from action to files
parfeon Dec 2, 2022
12a8e1f
refactor(github-actions): remove debug build output because it always…
parfeon Dec 2, 2022
e6724b0
fix(github-actions): fix echo bad substitution error
parfeon Dec 2, 2022
7545d9d
fix(github-actions): add missing input to unit test script
parfeon Dec 2, 2022
837abe8
Merge branch 'master' into test/switch-to-actions
parfeon Dec 2, 2022
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
4 changes: 2 additions & 2 deletions .github/workflows/commands-handler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
token: ${{ secrets.GH_TOKEN }}
- name: Checkout release actions
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
repository: pubnub/client-engineering-deployment-tools
ref: v1
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
name: Tests runner
description: Unit and integration tests runner for multiple compiler types.
author: PubNub
inputs:
os:
description: Environment in which framework should be built.
required: true
version:
description: "Which version of 'cgreen' should be built."
required: true
pubNubPubKey:
description: "PubNub publish keys which should be used with integration tests"
required: true
pubNubSubKey:
description: "PubNub subscribe keys which should be used with integration tests"
required: true

runs:
using: "composite"
steps:
- name: Prepare environments
shell: bash
run: |
echo "PUBNUB_PUBKEY=${{ inputs.pubNubPubKey }}" >> $GITHUB_ENV
echo "PUBNUB_KEYSUB=${{ inputs.pubNubSubKey }}" >> $GITHUB_ENV
- name: Pull Unit Test framework ('${{ inputs.os }}' gcc, clang)
uses: ./.github/workflows/composite/unit-test-framework
with:
os: ${{ inputs.os }}
version: ${{ inputs.version }}
compilers: gcc,clang
- name: Prepare Unit Test framework ('${{ inputs.os }}' gcc)
shell: bash
run: |
mv "$GITHUB_WORKSPACE/cgreen" "$GITHUB_WORKSPACE/cgreen-universal"
cp -r "$GITHUB_WORKSPACE/cgreen-universal/gcc" "$GITHUB_WORKSPACE/cgreen"
- name: Run unit tests ('${{ inputs.os }}' gcc)
shell: bash
env:
CC: gcc
CXX: "g++"
run: .github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh ${{ inputs.os }}
- name: Run integration tests ('${{ inputs.os }}' gcc)
shell: bash
env:
CC: gcc
CXX: "g++"
run: .github/workflows/composite/unit-integration-test-runner/run-integration-tests.sh ${{ inputs.os }}
- name: Prepare Unit Test framework ('${{ inputs.os }}' clang)
shell: bash
run: |
rm -rf "$GITHUB_WORKSPACE/cgreen"
cp -r "$GITHUB_WORKSPACE/cgreen-universal/clang" "$GITHUB_WORKSPACE/cgreen"
- name: Run unit tests ('${{ inputs.os }}' clang)
shell: bash
env:
CC: clang
CXX: "clang++"
run: .github/workflows/composite/unit-integration-test-runner/run-unit-tests.sh ${{ inputs.os }}
- name: Run integration tests ('${{ inputs.os }}' clang)
shell: bash
env:
CC: clang
CXX: "clang++"
run: .github/workflows/composite/unit-integration-test-runner/run-integration-tests.sh ${{ inputs.os }}
- name: Restore Unit Test framework ('${{ inputs.os }}' gcc,clang)
shell: bash
run: |
rm -rf "$GITHUB_WORKSPACE/cgreen"
cp -r "$GITHUB_WORKSPACE/cgreen-universal" "$GITHUB_WORKSPACE/cgreen"
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

INFO_BG="\033[0m\033[48;2;5;49;70m"
INFO_FG="\033[38;2;19;181;255m"
BOLD_INFO_FG="${INFO_FG}\033[1m"
SUCCESS_BG="\033[0m\033[48;2;30;69;1m"
SUCCESS_FG="\033[38;2;95;215;0m"
BOLD_SUCCESS_FG="${SUCCESS_FG}\033[1m"
CLEAR="\033[0m"

echo "::group::Run integration tests ('$1' $CC / $CXX)"
cd "$GITHUB_WORKSPACE"

if ! build="$(make -f posix.mk clean all 2>&1)"; then
echo "::error file=posix.mk::Unable to build test suite: $build"
exit 1
else
echo -e "${SUCCESS_BG}Test suit is built 🎉${CLEAR}"
fi

[[ "$build" =~ "deprecated" ]] && echo "::warning title=deprecated::There is deprecated functions used in code."
[[ "$build" =~ "not used" ]] && echo "::warning title=unused::There is unused variables and / or functions in code."

echo -e "${INFO_BG}${INFO_FG}Running ${BOLD_INFO_FG}POSIX ${INFO_BG}${INFO_FG}integration tests...${CLEAR}"
posix/pubnub_fntest
echo -e "${SUCCESS_BG}${BOLD_SUCCESS_FG}POSIX ${SUCCESS_BG}${SUCCESS_FG}integration tests completed 🎉${CLEAR}"
echo -e "${INFO_BG}${INFO_FG}Running ${BOLD_INFO_FG}OpenSSL ${INFO_BG}${INFO_FG}integration tests${CLEAR}"
openssl/pubnub_fntest
echo -e "${SUCCESS_BG}${BOLD_SUCCESS_FG}POSIX ${SUCCESS_BG}${SUCCESS_FG}integration tests completed 🎉${CLEAR}"
echo -e "${INFO_BG}${INFO_FG}Running ${BOLD_INFO_FG}C++ ${INFO_BG}${INFO_FG}integration tests${CLEAR}"
cpp/fntest_runner
echo -e "${SUCCESS_BG}${BOLD_SUCCESS_FG}POSIX ${SUCCESS_BG}${SUCCESS_FG}integration tests completed 🎉${CLEAR}"
echo -e "${INFO_BG}${INFO_FG}Running ${BOLD_INFO_FG}C++ OpenSSL ${INFO_BG}${INFO_FG}integration tests${CLEAR}"
cpp/openssl/fntest_runner
echo -e "${SUCCESS_BG}${BOLD_SUCCESS_FG}POSIX ${SUCCESS_BG}${SUCCESS_FG}integration tests completed 🎉${CLEAR}"
echo "::endgroup::"
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

echo "::group::Run unit tests ('$1' $CC / $CXX)"
cd "$GITHUB_WORKSPACE/core"
make clean generate_report
cd "$GITHUB_WORKSPACE/lib"
make clean generate_report
echo "::endgroup::"
38 changes: 38 additions & 0 deletions .github/workflows/composite/unit-test-framework/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: Unit Test and Mocking framework
description: Manage unit test framework build and cache so it can be used with jobs.
author: PubNub
inputs:
os:
description: Environment in which framework should be built.
required: true
version:
description: "Which version of 'cgreen' should be built."
required: true
compilers:
description: "Coma-separated list of currently supported C compilers to be used during build (gcc, clang)."
required: true

runs:
using: "composite"
steps:
- name: Build and Cache Unit Test framework ('${{ inputs.os }}' ${{ inputs.compilers }})
id: unit-test-framework
uses: actions/cache@v3
with:
path: |
cgreen
key: ${{ inputs.os }}-cgreen-${{ inputs.version }}-1
restore-keys: |
${{ inputs.os }}-cgreen-${{ inputs.version }}-
- name: Checkout Unit Test framework
if: steps.unit-test-framework.outputs.cache-hit != 'true'
uses: actions/checkout@v3
with:
repository: cgreen-devs/cgreen
ref: ${{ matrix.cgreen }}
path: cgreen
- name: Build Unit Test frameworks
if: steps.unit-test-framework.outputs.cache-hit != 'true'
shell: bash
run: .github/workflows/composite/unit-test-framework/build-framework.sh ${{ inputs.os }} ${{ inputs.compilers }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash

# Identify make tool which depends from environment.
[[ $1 =~ (ubuntu|macos) ]] && MAKE_TOOL=make || MAKE_TOOL=$(MAKE)

# Iterating over list of passed compilers.
for compiler in ${2//,/ }
do
# Navigate to unit test framework source folder.
cd "$GITHUB_WORKSPACE/cgreen"

# Clean up previous build results.
[[ -d build ]] && $MAKE_TOOL clean && rm -rf build

echo "::group::Build unit test framework ('$1' $compiler)"
if [[ $1 =~ (ubuntu|macos) ]]; then
export CC="$compiler"
[[ $compiler == "gcc" ]] && export CXX="g++" || export CXX="$compiler++"
else
echo "::warning title=compiler flags::Here should be some setup for Windows compiler"
fi

echo "::notice title=cgreen::Prepare folders structure"
! [[ -d "$GITHUB_WORKSPACE/cgreen-tmp/$compiler" ]] &&
mkdir -p "$GITHUB_WORKSPACE/cgreen-tmp/$compiler"
mkdir -p build && cd build

# Enable 'gcov' only for build on Ubuntu.
[[ "$1" == "ubuntu" ]] && WITH_GCOV=ON || WITH_GCOV=OFF
if [[ "$WITH_GCOV" == ON ]]; then
echo "::notice title=gcov::Installing 'gcov' for code coverage."
if ! install="$(pip install --user gcovr)"; then
echo "::error title=gcov::Unable to install 'gcov':$install"
else
echo "::notice title=gcov::Installing 'gcov' for code coverage."
fi
else
echo "::warning title=gcov::'gcov' doesn't work as expected on $1."
echo "::warning title=gcov::Configure 'cgreen' without 'gcov' support"
fi

echo "::notice title=cgreen::Configure 'cgreen' build"
cmake -E env LDFLAGS="-lm" cmake -DCGREEN_INTERNAL_WITH_GCOV:BOOL=$WITH_GCOV ..

echo "::notice title=cgreen::Build 'cgreen' framework"
make -j2

echo "::notice::Move built results to compiler specific colder"
mv "$GITHUB_WORKSPACE/cgreen/build" "$GITHUB_WORKSPACE/cgreen-tmp/$compiler/build"
cp -r "$GITHUB_WORKSPACE/cgreen/include" "$GITHUB_WORKSPACE/cgreen-tmp/$compiler/include"

# Clean up configured environments.
unset CC && unset CXX
echo "::endgroup::"
done

echo "::notice title=cgreen::Prepare files for caching"
rm -rf "$GITHUB_WORKSPACE/cgreen"
mv "$GITHUB_WORKSPACE/cgreen-tmp" "$GITHUB_WORKSPACE/cgreen"
10 changes: 5 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,25 @@ jobs:
release: ${{ steps.check.outputs.ready }}
steps:
- name: Checkout actions
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
repository: pubnub/client-engineering-deployment-tools
ref: v1
token: ${{ secrets.GH_TOKEN }}
path: .github/.release/actions
- id: check
name: Check pre-release completed
- name: Check pre-release completed
id: check
uses: ./.github/.release/actions/actions/checks/release
with:
token: ${{ secrets.GH_TOKEN }}
publish:
name: Publish package
runs-on: macos-11
runs-on: ubuntu-latest
needs: check-release
if: ${{ needs.check-release.outputs.release == 'true' }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
# This should be the same as the one specified for on.pull_request.branches
ref: master
Expand Down
120 changes: 120 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
name: Tests

concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

on:
push:
workflow_dispatch:


jobs:
tests-ubuntu:
name: Integration and Unit tests (Ubuntu)
runs-on: ubuntu-latest
steps:
- name: Checkout project
uses: actions/checkout@v3
with:
token: ${{ secrets.GH_TOKEN }}
- name: Build and run tests
uses: ./.github/workflows/composite/unit-integration-test-runner
with:
os: ubuntu
version: 1.6.0
pubNubPubKey: ${{ secrets.PUBNUB_PUBKEY }}
pubNubSubKey: ${{ secrets.PUBNUB_KEYSUB }}
tests-macos:
name: Integration and Unit tests (macOS)
runs-on: macos-latest
steps:
- name: Checkout project
uses: actions/checkout@v3
with:
token: ${{ secrets.GH_TOKEN }}
- name: Build and run tests
uses: ./.github/workflows/composite/unit-integration-test-runner
with:
os: macos
version: 1.6.0
pubNubPubKey: ${{ secrets.PUBNUB_PUBKEY }}
pubNubSubKey: ${{ secrets.PUBNUB_KEYSUB }}
acceptance:
name: Acceptance tests
runs-on: ubuntu-latest
steps:
- name: Setup environment
shell: bash
run: |
sudo apt-get install -y ninja-build libboost-all-dev libssl-dev
sudo gem install cucumber
- name: Checkout project
uses: actions/checkout@v3
with:
token: ${{ secrets.GH_TOKEN }}
- name: Checkout mock-server action
uses: actions/checkout@v3
with:
repository: pubnub/client-engineering-deployment-tools
ref: v1
token: ${{ secrets.GH_TOKEN }}
path: .github/.release/actions
- name: Run mock server action
uses: ./.github/.release/actions/actions/mock-server
with:
token: ${{ secrets.GH_TOKEN }}
- name: Pull Cucumber cache
id: cucumber-cpp
uses: actions/cache@v3
with:
path: |
cucumber-cpp
key: ${{ runner.os }}-cucumber-cpp-c79100eb70fbb34f6ea10030cec051c2cc9f7961
restore-keys: |
${{ runner.os }}-cucumber-cpp-
- name: Checkout Cucumber
if: steps.cucumber-cpp.outputs.cache-hit != 'true'
uses: actions/checkout@v3
with:
repository: cucumber/cucumber-cpp
ref: c79100eb70fbb34f6ea10030cec051c2cc9f7961
path: cucumber-cpp-src
- name: Build Cucumber
if: steps.cucumber-cpp.outputs.cache-hit != 'true'
shell: bash
run: |
cd ./cucumber-cpp-src
cmake -B build -DCMAKE_BUILD_TYPE=Debug
cmake --build build --config Debug
cd "$GITHUB_WORKSPACE"
mkdir -p cucumber-cpp
mv cucumber-cpp-src/build cucumber-cpp/build
mv cucumber-cpp-src/include cucumber-cpp/include
rm -rf cucumber-cpp-src
- name: Build acceptance tests
shell: bash
run: |
cd cpp
make -f posix_openssl.mk openssl/pubnub_sync
cd "$GITHUB_WORKSPACE"
g++ -std=c++11 -g -o BoostSteps.o -c features/step_definitions/BoostSteps.cpp -Icucumber-cpp/include -Icucumber-cpp/build/src/ -Iposix -Icore -I. -Icpp -D PUBNUB_CRYPTO_API=1 -D PUBNUB_USE_SSL=0
g++ -o steps BoostSteps.o cpp/pubnub_sync.a cucumber-cpp/build/src/libcucumber-cpp.a -Lboost -lboost_unit_test_framework -lpthread -lboost_regex -lboost_thread -lboost_program_options -lboost_filesystem -lssl -lcrypto -D PUBNUB_USE_SSL=0
- name: Run acceptance tests
shell: bash
env:
PAM_PUB_KEY: "pub_key"
PAM_SUB_KEY: "sub_key"
PAM_SEC_KEY: "sec_key"
run: |
mv sdk-specifications/features/access features
sudo python3 run_contract_tests.py features/access/grant-token.feature
sudo python3 run_contract_tests.py features/access/revoke-token.feature
ls -la results
- name: Expose acceptance tests reports
if: always()
uses: actions/upload-artifact@v3
with:
name: acceptance-test-reports
path: ./results/**
retention-days: 7
Loading