-
Notifications
You must be signed in to change notification settings - Fork 657
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Philipp Schlarb <p.schlarb@esatus.com>
- Loading branch information
Showing
6 changed files
with
493 additions
and
398 deletions.
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,149 @@ | ||
name: indy-node-push-and-pr | ||
on: | ||
push: | ||
branches: | ||
- ubuntu-20.04-upgrade | ||
|
||
pull_request: | ||
branches: | ||
- ubuntu-20.04-upgrade | ||
workflow_dispatch: | ||
|
||
jobs: | ||
workflow-setup: | ||
name: Initialize Workflow | ||
runs-on: ubuntu-latest | ||
outputs: | ||
CACHE_KEY_BUILD: ${{ steps.cache.outputs.CACHE_KEY_BUILD }} | ||
UBUNTU_VERSION: ${{ steps.cache.outputs.UBUNTU_VERSION }} | ||
# Expose the lowercase version of the GitHub repository name | ||
# to all subsequent jobs that reference image repositories | ||
# as the push and pull operations require the URL of the repository | ||
# to be in lowercase. | ||
GITHUB_REPOSITORY_NAME: ${{ steps.repository-name.outputs.lowercase }} | ||
GITHUB_REF: ${{ steps.cache.outputs.GITHUB_REF }} | ||
distribution: ${{ steps.cache.outputs.distribution }} | ||
isDev: ${{ steps.build-flags.outputs.isDev }} | ||
isRC: ${{ steps.build-flags.outputs.isRC }} | ||
publish: ${{ steps.build-flags.outputs.publish }} | ||
steps: | ||
- name: Git checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Convert the GitHub repository name to lowercase | ||
id: repository-name | ||
uses: ASzc/change-string-case-action@v1 | ||
with: | ||
string: ${{ github.repository }} | ||
|
||
- name: Set outputs | ||
id: cache | ||
run: | | ||
# Set variables according to version of ubuntu | ||
if [[ "${{github.base_ref}}" == "master" || "${{github.ref}}" == "refs/heads/master" ]]; then | ||
echo "::set-output name=CACHE_KEY_BUILD::${{ hashFiles('.github/workflows/build/Dockerfile.ubuntu-1604') }}" | ||
echo "::set-output name=UBUNTU_VERSION::ubuntu-1604" | ||
echo "::set-output name=distribution::xenial" | ||
fi | ||
if [[ "${{github.base_ref}}" == "ubuntu-20.04-upgrade" || "${{github.ref}}" == "refs/heads/ubuntu-20.04-upgrade" ]]; then | ||
echo "::set-output name=CACHE_KEY_BUILD::${{ hashFiles('.github/workflows/build/Dockerfile.ubuntu-2004') }}" | ||
echo "::set-output name=UBUNTU_VERSION::ubuntu-2004" | ||
echo "::set-output name=distribution::focal" | ||
fi | ||
|
||
if [[ "${{github.base_ref}}" == 'master' || "${{github.ref}}" == 'refs/heads/master' || "${{github.base_ref}}" == 'main' || "${{github.ref}}" == 'refs/heads/main' ]]; then | ||
echo "::set-output name=GITHUB_REF::main" | ||
elif [[ "${{github.base_ref}}" == 'release*' || "${{github.ref}}" == 'refs/heads/release*' ]]; then | ||
echo "::set-output name=GITHUB_REF::rc" | ||
elif [[ "${{github.base_ref}}" == 'stable' || "${{github.ref}}" == 'refs/heads/stable' ]]; then | ||
echo "::set-output name=GITHUB_REF::stable" | ||
else | ||
echo "::set-output name=GITHUB_REF::dev" | ||
fi | ||
|
||
- name: Set build flags | ||
id: build-flags | ||
run: | | ||
if [[ "${{steps.cache.outputs.GITHUB_REF}}" == 'dev' || "${{steps.cache.outputs.GITHUB_REF}}" == 'main' ]]; then | ||
echo "::set-output name=isDev::true" | ||
else | ||
echo "::set-output name=isDev::false" | ||
fi | ||
if [[ "${{steps.cache.outputs.GITHUB_REF}}" == 'rc' ]]; then | ||
echo "::set-output name=isRC::true" | ||
else | ||
echo "::set-output name=isRC::false" | ||
fi | ||
# Ensure publishing is only performed when the build is executed from the main (hyperledger/indy-node) repository. | ||
if [[ ${{github.event.repository.full_name}} == 'hyperledger/indy-node' && ${{github.event_name}} == 'push' && ( ${{steps.cache.outputs.GITHUB_REF}} == 'main' || ${{steps.cache.outputs.GITHUB_REF}} == 'rc' || ${{steps.cache.outputs.GITHUB_REF}} == 'stable' || ${{steps.cache.outputs.GITHUB_REF}} == 'dev' ) ]]; then | ||
echo "::set-output name=publish::true" | ||
else | ||
echo "::set-output name=publish::false" | ||
fi | ||
lint: | ||
name: Lint | ||
# Reference to workflow-setup job is required to access the GITHUB_REPOSITORY_NAME output. | ||
needs: [workflow-setup] | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.8' | ||
- uses: actions/cache@v2 | ||
with: | ||
path: ~/.cache/pip | ||
key: ${{ runner.os }}-pip-lint | ||
restore-keys: | | ||
${{ runner.os }}-pip-lint | ||
- name: Install flake8 | ||
run: pip install flake8==3.8.4 pep8==1.7.1 pep8-naming==0.6.1 | ||
- name: Lint with flake8 | ||
run: python3 -m flake8 . | ||
|
||
build-image: | ||
name: Create Builder Image | ||
needs: [workflow-setup, lint] | ||
uses: ./.github/workflows/buildimage.yaml | ||
with: | ||
CACHE_KEY_BUILD: ${{ needs.workflow-setup.outputs.CACHE_KEY_BUILD }} | ||
GITHUB_REPOSITORY_NAME: ${{ needs.workflow-setup.outputs.GITHUB_REPOSITORY_NAME }} | ||
UBUNTU_VERSION: ${{ needs.workflow-setup.outputs.UBUNTU_VERSION }} | ||
|
||
indy_node_tests: | ||
name: Indy Node Tests | ||
needs: [workflow-setup, build-image] | ||
uses: ./.github/workflows/test.yaml | ||
with: | ||
GITHUB_REPOSITORY_NAME: ${{ needs.workflow-setup.outputs.GITHUB_REPOSITORY_NAME }} | ||
UBUNTU_VERSION: ${{ needs.workflow-setup.outputs.UBUNTU_VERSION }} | ||
|
||
build_packages: | ||
name: Build Packages | ||
needs: [workflow-setup, indy_node_tests] | ||
uses: ./.github/workflows/buildpackages.yaml | ||
with: | ||
GITHUB_REPOSITORY_NAME: ${{ needs.workflow-setup.outputs.GITHUB_REPOSITORY_NAME }} | ||
UBUNTU_VERSION: ${{ needs.workflow-setup.outputs.UBUNTU_VERSION }} | ||
isDev: ${{ needs.workflow-setup.outputs.isDev }} | ||
isRC: ${{ needs.workflow-setup.outputs.isRC }} | ||
|
||
publish_artifacts: | ||
name: Publish Artifacts | ||
needs: [workflow-setup, build_packages] | ||
if: needs.workflow-setup.outputs.publish == 'true' | ||
uses: ./.github/workflows/publish_artifacts.yaml | ||
with: | ||
GITHUB_REF: ${{ needs.workflow-setup.outputs.GITHUB_REF }} | ||
UBUNTU_VERSION: ${{ needs.workflow-setup.outputs.UBUNTU_VERSION }} | ||
distribution: ${{ needs.workflow-setup.outputs.distribution }} | ||
secrets: | ||
INDY_ARTIFACTORY_REPO_CONFIG: ${{ secrets.INDY_ARTIFACTORY_REPO_CONFIG }} | ||
PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }} |
Oops, something went wrong.