Skip to content

Commit 8e22751

Browse files
authored
Merge pull request #46 from dylon/dylon/ci-workflow
Adds CI Pipeline with GitHub Actions
2 parents 57baeaa + 8568a3b commit 8e22751

28 files changed

Lines changed: 2035 additions & 1119 deletions

.github/apt-dependencies.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
autoconf
2+
cmake
3+
curl
4+
git
5+
jflex
6+
libtool
7+
make
8+
protobuf-compiler
9+
sbt
10+
unzip

.github/cabal-dependencies.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
alex
2+
happy
3+
BNFC

.github/init-environment

Lines changed: 0 additions & 181 deletions
This file was deleted.

.github/print-integration-test-selection

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,10 @@ import shlex
3030

3131
from shared import REMAINDER, get_test_selections
3232

33-
JOB_NAME = 'run_integration_tests'
34-
3533
test_sel = os.environ['TESTS'].strip()
3634

3735
if test_sel == REMAINDER:
38-
selections = [*get_test_selections(JOB_NAME)]
36+
selections = [*get_test_selections()]
3937
if selections:
4038
test_sel = 'not ((' + ') or ('.join(selections) + '))'
4139
else:

.github/run-integration-test-selection

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,6 @@
11
#!/bin/bash
22
set -eu -o pipefail
33

4-
# Run init-environment script to prepare filesystem for GitHub CI caching.
5-
#
6-
# Normally the init-environment script prints variables in format that GitHub CI
7-
# understands[1]. Setting GITHUB_ACTIONS to other value than true turns it into
8-
# format that can be fed into eval. We don't necessarily need the variables it
9-
# produces. Those are used only in workflow (cache related variables). But
10-
# someone may initialize more variables there anyway and expect to see them in
11-
# integration tests.
12-
#
13-
# When [2] is fixed, we can remove this and run whole job in the rchain/buildenv
14-
# container. See comments in run_integration_tests job for more information.
15-
#
16-
# [1] https://help.github.com/en/actions/automating-your-workflow-with-github-actions/development-tools-for-github-actions#set-an-environment-variable-set-env
17-
# [2] https://github.community/t5/GitHub-Actions/Container-volumes-key-not-mounting-volume/m-p/34798
18-
eval "$(GITHUB_ACTIONS= ./.github/init-environment || echo false)"
19-
204
# Store virtualenv in integration-tests/.venv instead of the magic path with
215
# hash that Pipenv creates, so that it remains on known path for easy caching.
226
export PIPENV_VENV_IN_PROJECT=1
@@ -28,19 +12,20 @@ export PIPENV_VENV_IN_PROJECT=1
2812
# printed after all tests finish.
2913
export PYTEST_ADDOPTS="${PYTEST_ADDOPTS-} --log-cli-level=ERROR"
3014

15+
# The virtual environment should have been initialized at this point.
16+
export _SKIP_VIRTUALENV_INIT=1
17+
3118
if [[ $TESTS != REMAINDER ]]; then
3219
# Check code (Pylint & mypy) only once, when running the REMAINDER
3320
# selection. Do not remove/modify REMAINDER selection!
3421
export _SKIP_CHECK_CODE=1
3522
fi
3623

37-
test_selection="$(./.github/print-integration-test-selection)"
38-
39-
40-
cd integration-tests/
24+
GITHUB_DIR="$(dirname "$0")"
25+
TEST_SELECTION="$("$GITHUB_DIR/print-integration-test-selection")"
4126

4227
ret=0
43-
./run_tests -k "$test_selection" || ret=$?
28+
./run_tests -k "$TEST_SELECTION" || ret=$?
4429

4530
# Exit code 5: No tests were collected
4631
# Source: http://doc.pytest.org/en/latest/usage.html#possible-exit-codes

.github/run-unit-test-selection

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,11 @@ from subprocess import run
3636

3737
from shared import REMAINDER, get_test_selections
3838

39-
JOB_NAME = 'run_unit_tests'
40-
4139
test_sel = os.environ['TESTS'].strip()
4240

4341
if test_sel == REMAINDER:
4442
sbt_args = []
45-
for arg in chain(*map(shlex.split, get_test_selections(JOB_NAME))):
43+
for arg in chain(*map(shlex.split, get_test_selections())):
4644
match = re.match('(?:([-\\w]+)/)?((?:it:)?test)', arg)
4745
if match:
4846
project, task = match[1], match[2]

.github/shared.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
import yaml
66

7-
WORKFLOW_PROJECT_PATH = '.github/workflows/continuous-integration.yml'
7+
GITHUB_DIR = os.path.dirname(os.path.abspath(__file__))
8+
REQUIRED_WORKFLOW_PATH = GITHUB_DIR + '/workflows/build-test-and-deploy.yml'
9+
OPTIONAL_WORKFLOW_PATH = GITHUB_DIR + '/workflows/optional-tests.yml'
810
REMAINDER = 'REMAINDER'
911

1012

@@ -14,21 +16,21 @@ def get_project_root() -> Path:
1416
return Path(os.getenv('PROJECT_ROOT', os.getcwd()))
1517

1618

17-
def read_workflow() -> dict:
18-
"""Reads continuous-integration.yml workflow as dict"""
19-
workflow_path = get_project_root() / WORKFLOW_PROJECT_PATH
19+
def read_workflow(workflow_path: Path) -> dict:
20+
"""Reads YAML workflow as dict"""
2021
with open(workflow_path) as f:
2122
return yaml.safe_load(f)
2223

2324

24-
def get_test_selections(job_name: str) -> Iterable[str]:
25-
workflow = read_workflow()
26-
job = workflow['jobs'][job_name]
27-
28-
try:
29-
selections = job['strategy']['matrix']['tests']
30-
except KeyError:
31-
return []
25+
def get_test_selections() -> Iterable[str]:
26+
project_root = get_project_root()
27+
required_workflow_path = project_root / REQUIRED_WORKFLOW_PATH
28+
optional_workflow_path = project_root / OPTIONAL_WORKFLOW_PATH
29+
required_workflow = read_workflow(required_workflow_path)
30+
optional_workflow = read_workflow(optional_workflow_path)
31+
selections = \
32+
required_workflow['jobs']['run_required_scala_unit_tests']['strategy']['matrix']['tests'] + \
33+
optional_workflow['jobs']['run_optional_scala_unit_tests']['strategy']['matrix']['tests']
3234

3335
remainder_found = False
3436

0 commit comments

Comments
 (0)