-
Notifications
You must be signed in to change notification settings - Fork 658
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
add build file for github actions #1622
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
### Github Actions Workflow | ||
|
||
This build file replaces the existing `Jenkins.ci` build process. | ||
|
||
`lint.yaml` replaces the `Static code validation` stage of the Jenkins build. | ||
|
||
`build.yaml` replaces the `Build / Test` stage of the Jenkins build. | ||
|
||
Many of the other stages are replaced merely by the fact we're using Github Actions, we use prebuild Docker containers so we don't have to replicate the steps for building containers. | ||
|
||
The `Build result notification` stage was not moved to GHA, build failures will be reports via GHA. | ||
|
||
The build process for `Jenkins.nightly` was not ported to GHA. | ||
|
||
#### Configuring actions | ||
|
||
If you are cloning or forking this repo you will need to configure two secrets for Actions to run correctly. | ||
|
||
Secrets can be set via Settings -> Secrets -> New repository secret. | ||
|
||
CR_USER is your GH username. | ||
CR_PAT can be created by following [these directions](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token) | ||
|
||
Once you have run the build once with those secrets, you have to make then package public. | ||
Access the package at https://ghcr.io/USER/indy-node/indy-node-build or https://ghcr.io/USER/indy-node/indy-node-lint then change the visibility in 'Package Settings' to 'Public' then re-run the build. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
name: indy-node-build | ||
on: [ push, pull_request ] | ||
|
||
jobs: | ||
workflow-setup: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
CACHE_KEY_LINT: ${{ steps.cache.outputs.CACHE_KEY_LINT }} | ||
CACHE_KEY_BUILD: ${{ steps.cache.outputs.CACHE_KEY_BUILD }} | ||
steps: | ||
- name: Git checkout | ||
uses: actions/checkout@v2 | ||
- name: Set outputs | ||
id: cache | ||
run: | | ||
echo "::set-output name=CACHE_KEY_LINT::${{ hashFiles('.github/workflows/lint/Dockerfile') }}" | ||
echo "::set-output name=CACHE_KEY_BUILD::${{ hashFiles('.github/workflows/build/Dockerfile') }}" | ||
build-lint-image: | ||
needs: workflow-setup | ||
runs-on: ubuntu-latest | ||
env: | ||
DOCKER_BUILDKIT: 1 | ||
CACHE_KEY_LINT: ${{ needs.workflow-setup.outputs.CACHE_KEY_LINT }} | ||
steps: | ||
- name: Git checkout | ||
uses: actions/checkout@v2 | ||
- name: Try load from cache. | ||
id: cache-image-lint | ||
uses: actions/cache@v2 | ||
with: | ||
path: ${GITHUB_WORKSPACE}/cache | ||
key: ${{ env.CACHE_KEY_LINT }} | ||
- name: If NOT found in cache, build and push image. | ||
if: steps.cache-image-lint.outputs.cache-hit != 'true' | ||
run: | | ||
echo ${{ secrets.CR_PAT }} | docker login ghcr.io --username ${{ secrets.CR_USER }} --password-stdin | ||
docker build -f .github/workflows/lint/Dockerfile --no-cache -t ${GITHUB_REPOSITORY}/indy-node-lint:${{ env.CACHE_KEY_LINT }} . | ||
docker tag ${GITHUB_REPOSITORY}/indy-node-lint:${{ env.CACHE_KEY_LINT }} ghcr.io/${GITHUB_REPOSITORY}/indy-node-lint:latest | ||
docker push ghcr.io/${GITHUB_REPOSITORY}/indy-node-lint:latest | ||
mkdir -p ${GITHUB_WORKSPACE}/cache | ||
touch ${GITHUB_WORKSPACE}/cache/${{ env.CACHE_KEY_LINT }} | ||
build-test-image: | ||
needs: workflow-setup | ||
runs-on: ubuntu-latest | ||
env: | ||
DOCKER_BUILDKIT: 1 | ||
CACHE_KEY_BUILD: ${{ needs.workflow-setup.outputs.CACHE_KEY_BUILD }} | ||
steps: | ||
- name: Git checkout | ||
uses: actions/checkout@v2 | ||
- name: Try load from cache. | ||
id: cache-image-build | ||
uses: actions/cache@v2 | ||
with: | ||
path: ${GITHUB_WORKSPACE}/cache | ||
key: ${{ env.CACHE_KEY_BUILD }} | ||
- name: If NOT found in cache, build and push image. | ||
if: steps.cache-image-build.outputs.cache-hit != 'true' | ||
run: | | ||
echo ${{ secrets.CR_PAT }} | docker login ghcr.io --username ${{ secrets.CR_USER }} --password-stdin | ||
docker build -f .github/workflows/build/Dockerfile --no-cache -t ${GITHUB_REPOSITORY}/indy-node-build:${{ env.CACHE_KEY_BUILD }} . | ||
docker tag ${GITHUB_REPOSITORY}/indy-node-build:${{ env.CACHE_KEY_BUILD }} ghcr.io/${GITHUB_REPOSITORY}/indy-node-build:latest | ||
docker push ghcr.io/${GITHUB_REPOSITORY}/indy-node-build:latest | ||
mkdir -p ${GITHUB_WORKSPACE}/cache | ||
touch ${GITHUB_WORKSPACE}/cache/${{ env.CACHE_KEY_BUILD }} | ||
decorator-checks: | ||
name: Run decorator checks | ||
needs: | ||
- build-test-image | ||
- lint | ||
runs-on: ubuntu-18.04 | ||
container: | ||
image: ghcr.io/${{ github.repository }}/indy-node-build | ||
outputs: | ||
matrix-common: ${{ steps.ctd.outputs.matrix-common }} | ||
matrix-node: ${{ steps.ctd.outputs.matrix-node }} | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Check test decorators | ||
id: ctd | ||
run: | | ||
chmod +x ./scripts/run_pytest_check.sh | ||
./scripts/run_pytest_check.sh | ||
indy_common: | ||
name: Build Indy Common | ||
needs: decorator-checks | ||
runs-on: ubuntu-18.04 | ||
container: | ||
image: ghcr.io/${{ github.repository }}/indy-node-build | ||
strategy: | ||
matrix: ${{fromJson(needs.decorator-checks.outputs.matrix-common)}} | ||
fail-fast: false | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install dependencies | ||
run: pip install .[tests] | ||
continue-on-error: true | ||
|
||
- name: Run Indy Common tests | ||
run: python3 -m pytest -l -m ${{ matrix.module }} -vv --junitxml=test-result-common-${{ matrix.module }}.xml indy_common | ||
|
||
- name: Publish Test Report | ||
uses: scacap/action-surefire-report@v1 | ||
with: | ||
check_name: Indy Common ${{ matrix.module }} Test Report | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
report_paths: test-result-common-${{ matrix.module }}.xml | ||
|
||
indy_node: | ||
name: Build Indy Node | ||
needs: decorator-checks | ||
runs-on: ubuntu-18.04 | ||
container: | ||
image: ghcr.io/${{ github.repository }}/indy-node-build | ||
strategy: | ||
matrix: ${{fromJson(needs.decorator-checks.outputs.matrix-node)}} | ||
fail-fast: false | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install dependencies | ||
run: pip install .[tests] | ||
continue-on-error: true | ||
|
||
- name: Run Indy Node ${{ matrix.module }} tests | ||
run: python3 -m pytest -l -m ${{ matrix.module }} -vv --junitxml=test-result-node-${{ matrix.module }}.xml indy_node | ||
|
||
- name: Publish Test Report | ||
uses: scacap/action-surefire-report@v1 | ||
with: | ||
check_name: Indy Node ${{ matrix.module }} Test Report | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
report_paths: test-result-node-${{ matrix.module }}.xml | ||
|
||
lint: | ||
name: Lint | ||
runs-on: ubuntu-latest | ||
container: | ||
image: ghcr.io/${{ github.repository }}/indy-node-lint | ||
needs: | ||
- build-lint-image | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
|
||
- name: flake8 | ||
run: python3 -m flake8 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
FROM hyperledger/indy-core-baseci:0.0.3-master | ||
LABEL maintainer="Hyperledger <hyperledger-indy@lists.hyperledger.org>" | ||
|
||
RUN apt-get update -y && apt-get install -y \ | ||
python3-nacl \ | ||
libindy-crypto=0.4.5 \ | ||
libindy=1.13.0~1420 \ | ||
# rocksdb python wrapper | ||
libbz2-dev \ | ||
zlib1g-dev \ | ||
liblz4-dev \ | ||
libsnappy-dev \ | ||
rocksdb=5.8.8 \ | ||
ursa=0.3.2-2 \ | ||
jq | ||
|
||
RUN indy_image_clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Building the build image | ||
|
||
This `Dockerfile` is used as part of the workflow, any changes to it will force the docker image to be rebuilt and that new image will be used to run the downstream workflow. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Package: /indy-crypto/ /libindy/ | ||
Pin: release l=Indy Main Repository | ||
Pin-Priority: 1000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
set -e | ||
set -x | ||
|
||
apt-get -y autoremove | ||
rm -rf /var/lib/apt/lists/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/bash | ||
set -e | ||
set -x | ||
|
||
USERID="$1" | ||
USERNAME="$2" | ||
|
||
useradd -ms /bin/bash -u "$USERID" "$USERNAME" | ||
|
||
USERHOME=$(eval echo "~$USERNAME") | ||
VENVPATH="$USERHOME/$3" | ||
su -c "virtualenv -p python3.5 \"$VENVPATH\"" - "$USERNAME" | ||
|
||
# TODO virtualenv activation seems as better approach | ||
# but it's more tricky (failed to find out how) to automate | ||
# that for all cases (e.g. non interactive docker run/exec) | ||
USER_PYTHON=$(su -c "which python" - "$USERNAME") | ||
USER_PIP=$(su -c "which pip" - "$USERNAME") | ||
|
||
ln -sf "${VENVPATH}/bin/python" "$USER_PYTHON" | ||
ln -sf "${VENVPATH}/bin/pip" "$USER_PIP" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Development | ||
FROM ubuntu:18.04 | ||
LABEL maintainer="Kevin Griffin <griffin.kev@gmail.com>" | ||
|
||
RUN apt-get update && apt-get dist-upgrade -y | ||
|
||
# Install environment | ||
RUN apt-get install -y \ | ||
git \ | ||
wget \ | ||
python3.5 \ | ||
python3-pip \ | ||
python-setuptools \ | ||
python3-nacl | ||
|
||
RUN pip3 install -U \ | ||
'pip<10.0.0' \ | ||
setuptools \ | ||
pep8==1.7.1 \ | ||
pep8-naming==0.6.1 \ | ||
flake8==3.5.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Building the lint image | ||
|
||
This `Dockerfile` is used as part of the workflow, any changes to it will force the docker image to be rebuilt and that new image will be used to run the downstream workflow. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The implementation of parallelizing tests looks pretty cool.
We already have
runner.py
for parallelizing tests. It would be great to replace it with something better, but maybe we could do it in the different PRs with adding a GitHub actions to make changes gradually?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how runner.py would parallelize in the same way, given this issues a run command for each permutation in the matrix, runner.py would spawn a single runner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't parallelize in the same way, but runner.py has
--test-only-slice
to run only some part of tests dividing them on directories.Example of using runner.py from indy-plenum CI:
RUSTPYTHONASYNCIODEBUG=0 python runner.py --pytest python -m pytest -l -vv --dir plenum --output test-result-plenum-1.jenkinsubuntu01.txt --test-only-slice 1/3
where 1/3 is a part which we want to launch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That particular runner and usage is already a part of the plenum GHA PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will look into the usage of slice for node.