From e6e41488fc465920a789c285abf036f6be95cca6 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Tue, 29 Mar 2022 13:30:24 +0300 Subject: [PATCH 001/130] Add new workflow for forks Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 605 ++++++++++++++++++++++ .github/workflows/build-iroha1-fork.yml | 650 ++++++++++++++++++++++++ 2 files changed, 1255 insertions(+) create mode 100644 .github/build-iroha1-fork.src.yml create mode 100644 .github/workflows/build-iroha1-fork.yml diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml new file mode 100644 index 00000000000..29e42425420 --- /dev/null +++ b/.github/build-iroha1-fork.src.yml @@ -0,0 +1,605 @@ +name: Iroha1-fork + +on: + pull_request_target: + branches: [ feature/DOPS-1651/enable-fork-build ] ## target branches + +env: + DOCKERHUB_ORG: hyperledger + +jobs: + ## GitHub Actions Workflow does not support yaml anchors + ## and that is why there is a workaround with make-workflows.sh + ## You should `pre-commit install` or use `pre-commit-hook.sh`, + ## anyway please read .github/README.md + check_workflow_yaml_coressponds_to_src_yaml: + runs-on: ubuntu-20.04 #ubuntu-latest + name: Check if github workflows were properly made from sources + steps: + - &step_show_context + name: Show context + run: | + echo "::group::GitHub context" + cat <<'END' + ${{ toJson(github) }} + END + echo "::endgroup::" + echo "::group::GitHub needs" + cat <<'END' + ${{ toJson(needs) }} + END + echo "::endgroup::" + - &step_detect_commented_pr + name: REF and SHA of commented PR to ENV + if: github.event.comment + run: > + curl -fsSL ${{github.event.issue.pull_request.url}} + -H "Authorization: token ${{github.token}}" | + jq -r ' + "PR_REF="+.head.ref, + "PR_SHA="+.head.sha, + "PR_NUM="+(.number|tostring), + "PR_REPO="+.head.repo.full_name' >>$GITHUB_ENV + - *step_show_context + - &step_checkout_base + name: Checkout base + uses: actions/checkout@v2 + with: &step_checkout_with_base + ref: ${{env.PR_REF}} ## not empty on issue_comment, else default value GITHUB_REF + repository: ${{env.PR_REPO}} ## not empty on issue_comment, else default value github.repository, required by forks + - + run: sudo snap install yq + - + name: Check if .github/workflows/*.yml correspond to *.src.yml + run: | + set -x + [[ $(./.github/make-workflows.sh -x --worktree) = *"everything is up to date" ]] + + + generate_matrixes: + runs-on: ubuntu-20.04 #ubuntu-latest + #container: ubuntu:latest + if: ${{ (github.event_name != 'comment') || ( github.event.comment && + github.event.issue.pull_request && + startsWith(github.event.comment.body, '/build') ) }} + steps: + - *step_show_context + - *step_detect_commented_pr + - *step_checkout_base + - + name: Generate matrix for build triggered by chat-ops - comment to PR + if: github.event.issue.pull_request && github.event.comment + id: comment_body + run: echo "${{github.event.comment.body}}" >/tmp/comment_body + - + name: Generate default matrix for regular builds + if: ${{ steps.comment_body.outcome == 'skipped' }} ## i.e. not github.event.issue.pull_request + run: | + set -x + git fetch origin ${{github.event.pull_request.head.sha}} --depth=2 ## depth=2 to detect if fetched commit is merge commit + git log -1 FETCH_HEAD + commit_message_body_build_spec(){ + git log -n1 $1 --format=%B | grep '^/build ' + } + git_is_merge_commit(){ + git rev-parse ${1:-HEAD}^2 &>/dev/null + } + commit_was_merged_build_spec(){ + git_is_merge_commit $1 && + git log -n1 $1 --format=%s | grep -q '^Merge branch' && + echo "/build before-merge" + } + case ${{github.event_name}} in + pull_request_target) if commit_message_body_build_spec FETCH_HEAD >/tmp/comment_body ;then + if git_is_merge_commit FETCH_HEAD ;then + echo ::warning::'/build directive in merge commit overrides default "/build before-merge"' + fi + elif commit_was_merged_build_spec FETCH_HEAD >/tmp/comment_body ;then + true + else + #echo >/tmp/comment_body "/build debug; /build ubuntu release debug normal" + #echo >/tmp/comment_body "/build all" + echo >/tmp/comment_body "/build ubuntu debug clang-10 normal" + fi ;; + esac + - + name: Generate matrixes + id: matrixes + run: | + set -x + cat /tmp/comment_body | .github/chatops-gen-matrix.sh + echo "::set-output name=matrix_ubuntu::$(cat matrix_ubuntu)" + echo "::set-output name=matrix_ubuntu_release::$(cat matrix_ubuntu_release)" + echo "::set-output name=matrix_ubuntu_debug::$(cat matrix_ubuntu_debug)" + echo "::set-output name=matrix_macos::$(cat matrix_macos)" + echo "::set-output name=matrix_windows::$(cat matrix_windows)" + echo "::set-output name=matrix_dockerimage_release::$(cat matrix_dockerimage_release)" + echo "::set-output name=matrix_dockerimage_debug::$(cat matrix_dockerimage_debug)" + ##TODO report errors and warnings as answer to issue comment (chat-ops) + - + name: Reaction confused + if: failure() && github.event.comment + run: | + # send reaction to comment to show build was triggered + curl ${{github.event.comment.url}}/reactions \ + -X POST \ + -d '{"content":"confused"}' \ + -H "Accept: application/vnd.github.squirrel-girl-preview+json" \ + -H "Authorization: token ${{github.token}}" + - + name: Reaction rocket + if: github.event.comment + run: | + # send reaction to comment to show build was triggered + curl ${{github.event.comment.url}}/reactions \ + -X POST \ + -d '{"content":"rocket"}' \ + -H "Accept: application/vnd.github.squirrel-girl-preview+json" \ + -H "Authorization: token ${{github.token}}" + outputs: + matrix_ubuntu: ${{steps.matrixes.outputs.matrix_ubuntu}} + matrix_ubuntu_release: ${{steps.matrixes.outputs.matrix_ubuntu_release}} + matrix_ubuntu_debug: ${{steps.matrixes.outputs.matrix_ubuntu_debug}} + matrix_macos: ${{steps.matrixes.outputs.matrix_macos}} + matrix_windows: ${{steps.matrixes.outputs.matrix_windows}} + matrix_dockerimage_release: ${{steps.matrixes.outputs.matrix_dockerimage_release}} + matrix_dockerimage_debug: ${{steps.matrixes.outputs.matrix_dockerimage_debug}} + + Docker-iroha-builder: + needs: check_workflow_yaml_coressponds_to_src_yaml + runs-on: ubuntu-20.04 #ubuntu-latest #[ self-hosted, Linux ] + # env: &env_dockerhub + # DOCKERHUB_ORG: DOCKERHUB_ORG ## Must be hyperledger, also can use iroha1, cannot use ${{ secrets.DOCKERHUB_ORG }} + # DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + # DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + steps: + - *step_show_context + - &step_system_info + name: System info + run: | + set -x + whoami + id $(whoami) + free || vm_stat | perl -ne '/page size of (\d+)/ and $size=$1; + /Pages\s+([^:]+)[^\d]+(\d+)/ and printf("%-16s % 16.2f Mi\n", "$1:", $2 * $size / 1048576);' + df -h + - &step_build_info + name: Build info + run: | + cat << 'END' + ref:${{github.ref}} + sha:${{github.sha}} + run_number:${{github.run_number}} + event_name:${{github.event_name}} + event.action:${{github.event.action}} + event.issue.number:${{ github.event.issue.number }} + END + - *step_detect_commented_pr + - &step_checkout_head + name: Checkout head + uses: actions/checkout@v2 + with: &step_checkout_with_head + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} + - &step_docker_tag + name: Determine dockertag + id: dockertag + env: + dockertag: ${{ hashFiles('docker/iroha-builder/**') }} + run: | + echo "::set-output name=dockertag::$dockertag" + echo >>$GITHUB_ENV dockertag=$dockertag + test -n "$DOCKERHUB_ORG" || { + echo ::error::"DOCKERHUB_ORG must contain value" + false + } + - &step_docker_login + name: Login to DockerHub + #if: ${{ secrets.DOCKERHUB_TOKEN != '' && secrets.DOCKERHUB_USERNAME != '' }} + id: docker_login + uses: docker/login-action@v1 + with: + #username: ${{ secrets.DOCKERHUB_USERNAME }} + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - &step_docker_login_ghcr + name: Log in to the Container registry GHCR + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - &step_warn_docker_no_push + name: Possible WARNING + if: ${{ steps.docker_login.outcome == 'skipped' }} + run: echo "::warning::DOCKERHUB_TOKEN and DOCKERHUB_USERNAME are empty. Will build but NOT push." + - &step_docker_meta + name: Docker meta + id: meta + uses: docker/metadata-action@v3 + with: &step_docker_meta_with + images: ${{ env.DOCKERHUB_ORG }}/iroha-builder + tags: | + type=raw,value=${{env.dockertag}} + type=ref,event=branch + type=ref,event=pr + type=ref,event=tag + type=schedule + ## Docker image will be pushed with tags: + ## - hash of file Dockerfile.builder + ## - branchname, when branch is pushed + ## - pr-NUMBER, when pushed to PR + ## - git tag when tag is pushed + ## - schedule, see the docs + - &step_docker_meta_ghcr + <<: *step_docker_meta + name: Docker meta GHCR + id: meta_ghcr + with: + <<: *step_docker_meta_with + images: ghcr.io/${{ github.repository }}-builder + - &step_docker_buildx + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - &step_docker_cache + name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{env.dockertag}} + restore-keys: ${{ runner.os }}-buildx- + - &step_docker_build_and_push + id: build_and_push + name: Build and push + uses: docker/build-push-action@v2 + with: &step_docker_build_and_push_with + context: docker/iroha-builder/ + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new + push: ${{ steps.docker_login.outcome == 'success' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + # env: + # DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + # DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + - &step_docker_build_and_push_ghcr + <<: *step_docker_build_and_push + id: build_and_push_ghcr + name: Build and push to GHCR + with: &step_docker_build_and_push_ghcr-with + <<: *step_docker_build_and_push_with + push: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo == github.event.pull_request.base.repo }} + tags: ${{ steps.meta_ghcr.outputs.tags }} + labels: ${{ steps.meta_ghcr.outputs.labels }} + # env: + # DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + # DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + - &step_docker_move_cache + # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache + - + name: Check if dockertaghash exists in remote registry + id: dockertag_already + run: | + echo "::set-output name=container::$DOCKERHUB_ORG/iroha-builder:$dockertag" + docker pull "$DOCKERHUB_ORG/iroha-builder:$dockertag" + - + name: Possible ERROR, Dockerfile edited, image was build, but seems not pushed, CANNOT PULL. + if: failure() + #if: ${{ steps.docker_login.outcome != 'success' || steps.build_and_push.outcome != 'success' }} + env: + container: ${{steps.dockertag_already.outputs.container}} + dockertag: ${{env.dockertag}} + run: | + cat </dev/null <<'END' + ${{ toJson(needs) }} + END + - + env: + container: *container_image + run: test -n "$container" + - *step_system_info + - *step_build_info + - &step_env_from_buildspec + name: export CC,BuildType from matrix.buildspec + run: | + echo >>$GITHUB_ENV OS=$(echo ${{matrix.buildspec}} | awk '{print $1}') + echo >>$GITHUB_ENV CC_NAME=$(echo ${{matrix.buildspec}} | awk '{print $2}') + echo >>$GITHUB_ENV BuildType=$(echo ${{matrix.buildspec}} | awk '{print $3}') + features=$(echo ${{matrix.buildspec}} | awk '{print $4}') + case $features in + normal) echo >>$GITHUB_ENV CMAKE_USE=""; features= ;; + ursa) echo >>$GITHUB_ENV CMAKE_USE="-DUSE_LIBURSA=ON";; + burrow) echo >>$GITHUB_ENV CMAKE_USE="-DUSE_BURROW=ON";; + *) echo "::error::Unknown features '$features'"; false ;; + esac + echo >>$GITHUB_ENV features="$features" + echo >>$GITHUB_ENV skip_testing=$(echo ${{matrix.buildspec}} | grep -Fo skip_testing) + - *step_detect_commented_pr + - &step_checkout_full + <<: *step_checkout_head + with: + <<: *step_checkout_with_head + fetch-depth: 0 ## full history + - &step_export_cxx + name: export CC and CXX + env: &step_export_cxx_env + CCACHE_PATH: /usr/lib/ccache + run: | + set -xeu #o pipefail + if test $CC_NAME = llvm + then CC=/usr/local/opt/llvm/bin/clang + else CC=$CC_NAME + fi + echo >>$GITHUB_ENV CC=$CC + echo >>$GITHUB_ENV CXX=$(echo $CC | sed -es,gcc,g++, -es,clang,clang++,) + echo >>$GITHUB_PATH $CCACHE_PATH + ls -lA $CCACHE_PATH + $(realpath $CCACHE_PATH/gcc) --show-config + echo >>$GITHUB_ENV _CCACHE_DIR=$($(realpath $CCACHE_PATH/gcc) --show-config | sed -nE 's,.*cache_dir = ,,p') + echo >>$GITHUB_ENV NPROC=$(nproc | awk '{printf("%.0f",$1*0.77)}') + echo >>$GITHUB_ENV HOME=$HOME + - &step_restore_ccache + name: Restore cache CCache + uses: actions/cache@v2 + with: + path: ${{ env._CCACHE_DIR }} + key: ${{runner.os}}-ccache-${{ github.event.pull_request.head.sha }} + restore-keys: ${{runner.os}}-ccache- + - &step_store_ccache_stats + run: ccache --show-stats | tee /tmp/ccache-stats + - &step_vcpkg_cache + ## Read the docs https://vcpkg.readthedocs.io/en/latest/users/binarycaching/ https://github.com/microsoft/vcpkg/blob/master/docs/users/binarycaching.md + name: Restore cache Vcpkg binarycache ## NOTE not useng NuGet because on ubuntu nuget needs mono of 433MB, unusable. + uses: actions/cache@v2 + with: + path: | + ${{env.HOME}}/.cache/vcpkg/archives + key: ${{runner.os}}-vcpkg-${{env.CC_NAME}}.${{ hashFiles('vcpkg/**') }} + restore-keys: ${{runner.os}}-vcpkg-${{env.CC_NAME}}. + - &step_vcpkg_build + name: Build iroha vcpkg dependancies + run: ./vcpkg/build_iroha_deps.sh $PWD/vcpkg-build; test -f $PWD/vcpkg-build/scripts/buildsystems/vcpkg.cmake + ## Takes 48m16s on default GitHub runner with 2 cores + ## Takes 13m41s on self-hosted AWS EC2 c5.x4large + # ________________________________________________________ + # Executed in 32,08 mins fish external + # usr time 110,52 mins 0,24 millis 110,52 mins + # sys time 12,26 mins 1,34 millis 12,26 mins + # + # All requested packages are currently installed. + # ________________________________________________________ + # Executed in 3,17 secs fish external + # usr time 2,05 secs 128,00 micros 2,05 secs + # sys time 0,70 secs 575,00 micros 0,70 secs + - &step_cmake_configure + name: CMake configure + ## Takes 13s on regular GitHub runner + run: cmake -B build -DCMAKE_TOOLCHAIN_FILE=$PWD/vcpkg-build/scripts/buildsystems/vcpkg.cmake + -DCMAKE_BUILD_TYPE=${{ env.BuildType }} + -GNinja + $CMAKE_USE + -DTESTING=$( test "$skip_testing" = skip_testing && echo OFF || echo ON ) + -DBENCHMARKING=$( test "$skip_testing" = skip_testing && echo OFF || echo ON ) + -DPACKAGE_DEB=ON + #-DCMAKE_VERBOSE_MAKEFILE=ON ## Note: use for debug + - &step_cmake_build + name: CMake build + run: | + set -x + ## reduce memory usage to do not overflow + cmake --build build --config ${{ env.BuildType }} -- -j$(nproc | awk '{printf("%.0f",$1*0.77)}') + echo ::notice::"$(./build/bin/irohad --version)" + ## Debug takes 18m44s on regular GitHub runner + ## Debug takes 7m41s on self-hosted AWS EC2 c5.x4large + ## Release takes 2m58s on self-hosted AWS EC2 c5.x4large + - &step_cpack + name: CPack (linux only) + run: cd build; cpack; ## cmake --build build --target package + - &step_compare_ccache_stats + run: ccache --show-stats | diff --side-by-side /tmp/ccache-stats - ||true + - &step_always_after_build + name: Show free space and disk usage + if: ${{ always() }} + run: | + df -h || true + - &step_artifact_suffix + name: Generate artifact suffix depending on matrix to env.ARTIFACT_SUFFIX + run: | + set -x + cc=$(echo $CC_NAME | sed -Ee's,[-/],,g' ) + build_type=$(echo $BuildType | tr A-Z a-z | sed -E -es,debug,dbg, -es,release,rel, ) + test $build_type = dbg -o $build_type = rel + uses=$(echo "$features" | tr ' ' - | tr A-Z a-z) + _os=${OS:+-$OS} _cc=${cc:+-$cc} _build_type=${build_type:+-$build_type} _uses=${uses:+-$uses} + echo >>$GITHUB_ENV ARTIFACT_SUFFIX=$_os$_cc$_build_type$_uses + echo >>$GITHUB_ENV _uses_suffix=$_uses + echo >>$GITHUB_ENV _compiler_suffix=$(test $cc != gcc9 && echo $_cc) + echo >>$GITHUB_ENV _debug_suffix=$(test "$build_type" = dbg && echo -debug || true) + - &step_artifact_irohad + name: Upload artifact irohad + uses: actions/upload-artifact@v2 + with: + name: irohad${{env.ARTIFACT_SUFFIX}} + path: &step_artifact_irohad_path | + build/bin/irohad + build/bin/iroha-cli + - &step_artifact_iroha_deb + name: Upload artifact iroha-deb + uses: actions/upload-artifact@v2 + with: + name: iroha-deb${{env.ARTIFACT_SUFFIX}} + path: &step_artifact_iroha_deb_path | + build/*.deb + - &step_artifact_tests + if: ${{ false }} ## Maybe test in another job + name: Upload artifact tests + uses: actions/upload-artifact@v2 + with: + name: iroha-tests-ubuntu${{env.ARTIFACT_SUFFIX}} + path: | + build/test_bin/** + build/test_data/** + - &step_ctest + timeout-minutes: 40 + if: env.skip_testing == '' + name: CTest + run: | + echo ::group::'boilerplate' + set -euo pipefail + if test $(uname) = Darwin ;then + ## This is a common portable solution, but Debian and Ubuntu have their own wrappers + initdb --locale=C --encoding=UTF-8 --username=postgres $PWD/postgres_database + postgres -D $PWD/postgres_database -p5432 2>&1 >/tmp/postgres.log & { sleep .3; kill -0 $!; } ## use pg_ctl no need & + else ## Debian or Ubuntu + ## Need to go debian-specific way because + ## initdb is not allowed to be run as root, but we need to run as root + ## because GitHub actions runners have much issues with permissions. + mkdir postgres_database && chown iroha-ci postgres_database + echo /usr/lib/postgresql/12/bin/initdb --locale=C --encoding=UTF-8 --username=postgres $PWD/postgres_database | su iroha-ci + echo /usr/lib/postgresql/12/bin/pg_ctl start -D $PWD/postgres_database --log=$PWD/postgres_database/log | su iroha-ci + # ## Need to go debian-specific way because + # ## initdb is not allowed to be run as root, but we need to run as root + # ## because GitHub actions runners have much issues with permissions. + # cat </etc/postgresql/12/main/pg_hba.conf + # # TYPE DATABASE USER ADDRESS METHOD + # local all all trust + # host all all 127.0.0.1/32 trust + # host all all ::1/128 trust + # local replication all trust + # host replication all 127.0.0.1/32 trust + # host replication all ::1/128 trust + # END + # pg_ctlcluster 12 main start ## Cluster 'main' exist by default + # #OR pg_createcluster -p 5432 --start 12 iroha -- --locale=C --encoding=UTF-8 --username=postgres + fi + cd build + + ## This is just a small lifehack to TEMPORARY allow some tests to fail + cat ../.github/TESTS_ALLOWED_TO_FAIL | sort -u >ALLOW_TO_FAIL || true + + if test -e ALLOW_TO_FAIL + then echo "::warning:: There are TESTS_ALLOWED_TO_FAIL: "$(cat ALLOW_TO_FAIL) + fi + + grep_failed_tests(){ + grep 'The following tests FAILED:' -A10000 "$@" | tail +2 #| cut -d- -f2 | cut -d' ' -f2 | sort + } + exclude_allowed_to_fail(){ + grep -Fvf ALLOW_TO_FAIL "$@" + } + only_allowed_to_fail(){ + grep -Ff ALLOW_TO_FAIL "$@" + } + list_to_line(){ + comma='' + while read N d name sta ;do + echo -n "$comma$N-$name$sta" + comma=', ' + done + } + echo ::endgroup:: + + ## Run module_* tests in parallel and others subsequently + ## Cathgories sorted in order of importancy + CTEST_CATHEGORIES=( module tool framework regression system integration ) + ## Add rest available cathgories + CTEST_CATHEGORIES+=( $( + ctest --show-only=json-v1 -R "^(module|tool|framework|regression|system|integration)" | + jq -r .tests[].name | + cut -f1 -d_ | + sort -u | + grep -Fvf <( printf '%s\n' ${CTEST_CATHEGORIES[@]} ) + ) + ) || true + CTEST_DEFAULT_timeout=80 + CTEST_module_timeout=120 CTEST_module_parallel=4 + CTEST_tool_timeout=200 + CTEST_integration_timeout=120 + CTEST_integration_args='--repeat until-pass:10' ## FIXME remove this hack + CTEST_system_args='--repeat until-pass:10' ## FIXME remove this hack + + for cathegory in ${CTEST_CATHEGORIES[@]} ;do + echo >&2 ::group::"$cathegory tests" + set -x + timeout_name=CTEST_${cathegory}_timeout; timeout=${!timeout_name:-$CTEST_DEFAULT_timeout} + parallel_name=CTEST_${cathegory}_parallel; parallel=${!parallel_name:-} + args_name=CTEST_${cathegory}_args; args=${!args_name:-} + ctest -R "^${cathegory}_" ${parallel:+--parallel $parallel} --output-on-failure --no-tests=error --timeout $timeout ${args:-} \ + | tee ctest_$cathegory.out \ + || true + set +x + echo >&2 ::endgroup:: + done + + tests_passed=true + for t in ${CTEST_CATHEGORIES[@]} ;do + f=ctest_$t.out + if a=$(grep_failed_tests $f | exclude_allowed_to_fail | list_to_line) ;then + echo "::error::The following $(echo $t | tr a-z A-Z) tests FAILED but not in list ALLOW_TO_FAIL: $a" + tests_passed=false + fi + if o=$(grep_failed_tests $f | only_allowed_to_fail | list_to_line) ;then + echo "::warning::The following $t tests FAILED and ALLOWED TO FAIL: $o" + fi + done + $tests_passed diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml new file mode 100644 index 00000000000..dc2a8be67c3 --- /dev/null +++ b/.github/workflows/build-iroha1-fork.yml @@ -0,0 +1,650 @@ +## DO NOT EDIT +## Generated from build-iroha1-fork.src.yml with make-workflows.sh + +name: Iroha1-fork +on: + pull_request_target: + branches: [feature/DOPS-1651/enable-fork-build] ## target branches +env: + DOCKERHUB_ORG: hyperledger +jobs: + ## GitHub Actions Workflow does not support yaml anchors + ## and that is why there is a workaround with make-workflows.sh + ## You should `pre-commit install` or use `pre-commit-hook.sh`, + ## anyway please read .github/README.md + check_workflow_yaml_coressponds_to_src_yaml: + runs-on: ubuntu-20.04 #ubuntu-latest + name: Check if github workflows were properly made from sources + steps: + - name: Show context + run: | + echo "::group::GitHub context" + cat <<'END' + ${{ toJson(github) }} + END + echo "::endgroup::" + echo "::group::GitHub needs" + cat <<'END' + ${{ toJson(needs) }} + END + echo "::endgroup::" + - name: REF and SHA of commented PR to ENV + if: github.event.comment + run: > + curl -fsSL ${{github.event.issue.pull_request.url}} -H "Authorization: token ${{github.token}}" | jq -r ' + + "PR_REF="+.head.ref, + "PR_SHA="+.head.sha, + "PR_NUM="+(.number|tostring), + "PR_REPO="+.head.repo.full_name' >>$GITHUB_ENV + - name: Show context + run: | + echo "::group::GitHub context" + cat <<'END' + ${{ toJson(github) }} + END + echo "::endgroup::" + echo "::group::GitHub needs" + cat <<'END' + ${{ toJson(needs) }} + END + echo "::endgroup::" + - name: Checkout base + uses: actions/checkout@v2 + with: + ref: ${{env.PR_REF}} ## not empty on issue_comment, else default value GITHUB_REF + repository: ${{env.PR_REPO}} ## not empty on issue_comment, else default value github.repository, required by forks + - run: sudo snap install yq + - name: Check if .github/workflows/*.yml correspond to *.src.yml + run: | + set -x + [[ $(./.github/make-workflows.sh -x --worktree) = *"everything is up to date" ]] + generate_matrixes: + runs-on: ubuntu-20.04 #ubuntu-latest + #container: ubuntu:latest + if: ${{ (github.event_name != 'comment') || ( github.event.comment && github.event.issue.pull_request && startsWith(github.event.comment.body, '/build') ) }} + steps: + - name: Show context + run: | + echo "::group::GitHub context" + cat <<'END' + ${{ toJson(github) }} + END + echo "::endgroup::" + echo "::group::GitHub needs" + cat <<'END' + ${{ toJson(needs) }} + END + echo "::endgroup::" + - name: REF and SHA of commented PR to ENV + if: github.event.comment + run: > + curl -fsSL ${{github.event.issue.pull_request.url}} -H "Authorization: token ${{github.token}}" | jq -r ' + + "PR_REF="+.head.ref, + "PR_SHA="+.head.sha, + "PR_NUM="+(.number|tostring), + "PR_REPO="+.head.repo.full_name' >>$GITHUB_ENV + - name: Checkout base + uses: actions/checkout@v2 + with: + ref: ${{env.PR_REF}} ## not empty on issue_comment, else default value GITHUB_REF + repository: ${{env.PR_REPO}} ## not empty on issue_comment, else default value github.repository, required by forks + - name: Generate matrix for build triggered by chat-ops - comment to PR + if: github.event.issue.pull_request && github.event.comment + id: comment_body + run: echo "${{github.event.comment.body}}" >/tmp/comment_body + - name: Generate default matrix for regular builds + if: ${{ steps.comment_body.outcome == 'skipped' }} ## i.e. not github.event.issue.pull_request + run: | + set -x + git fetch origin ${{github.event.pull_request.head.sha}} --depth=2 ## depth=2 to detect if fetched commit is merge commit + git log -1 FETCH_HEAD + commit_message_body_build_spec(){ + git log -n1 $1 --format=%B | grep '^/build ' + } + git_is_merge_commit(){ + git rev-parse ${1:-HEAD}^2 &>/dev/null + } + commit_was_merged_build_spec(){ + git_is_merge_commit $1 && + git log -n1 $1 --format=%s | grep -q '^Merge branch' && + echo "/build before-merge" + } + case ${{github.event_name}} in + pull_request_target) if commit_message_body_build_spec FETCH_HEAD >/tmp/comment_body ;then + if git_is_merge_commit FETCH_HEAD ;then + echo ::warning::'/build directive in merge commit overrides default "/build before-merge"' + fi + elif commit_was_merged_build_spec FETCH_HEAD >/tmp/comment_body ;then + true + else + #echo >/tmp/comment_body "/build debug; /build ubuntu release debug normal" + #echo >/tmp/comment_body "/build all" + echo >/tmp/comment_body "/build ubuntu debug clang-10 normal" + fi ;; + esac + - name: Generate matrixes + id: matrixes + run: | + set -x + cat /tmp/comment_body | .github/chatops-gen-matrix.sh + echo "::set-output name=matrix_ubuntu::$(cat matrix_ubuntu)" + echo "::set-output name=matrix_ubuntu_release::$(cat matrix_ubuntu_release)" + echo "::set-output name=matrix_ubuntu_debug::$(cat matrix_ubuntu_debug)" + echo "::set-output name=matrix_macos::$(cat matrix_macos)" + echo "::set-output name=matrix_windows::$(cat matrix_windows)" + echo "::set-output name=matrix_dockerimage_release::$(cat matrix_dockerimage_release)" + echo "::set-output name=matrix_dockerimage_debug::$(cat matrix_dockerimage_debug)" + ##TODO report errors and warnings as answer to issue comment (chat-ops) + - name: Reaction confused + if: failure() && github.event.comment + run: | + # send reaction to comment to show build was triggered + curl ${{github.event.comment.url}}/reactions \ + -X POST \ + -d '{"content":"confused"}' \ + -H "Accept: application/vnd.github.squirrel-girl-preview+json" \ + -H "Authorization: token ${{github.token}}" + - name: Reaction rocket + if: github.event.comment + run: | + # send reaction to comment to show build was triggered + curl ${{github.event.comment.url}}/reactions \ + -X POST \ + -d '{"content":"rocket"}' \ + -H "Accept: application/vnd.github.squirrel-girl-preview+json" \ + -H "Authorization: token ${{github.token}}" + outputs: + matrix_ubuntu: ${{steps.matrixes.outputs.matrix_ubuntu}} + matrix_ubuntu_release: ${{steps.matrixes.outputs.matrix_ubuntu_release}} + matrix_ubuntu_debug: ${{steps.matrixes.outputs.matrix_ubuntu_debug}} + matrix_macos: ${{steps.matrixes.outputs.matrix_macos}} + matrix_windows: ${{steps.matrixes.outputs.matrix_windows}} + matrix_dockerimage_release: ${{steps.matrixes.outputs.matrix_dockerimage_release}} + matrix_dockerimage_debug: ${{steps.matrixes.outputs.matrix_dockerimage_debug}} + Docker-iroha-builder: + needs: check_workflow_yaml_coressponds_to_src_yaml + runs-on: ubuntu-20.04 #ubuntu-latest #[ self-hosted, Linux ] + # env: &env_dockerhub + # DOCKERHUB_ORG: DOCKERHUB_ORG ## Must be hyperledger, also can use iroha1, cannot use ${{ secrets.DOCKERHUB_ORG }} + # DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + # DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + steps: + - name: Show context + run: | + echo "::group::GitHub context" + cat <<'END' + ${{ toJson(github) }} + END + echo "::endgroup::" + echo "::group::GitHub needs" + cat <<'END' + ${{ toJson(needs) }} + END + echo "::endgroup::" + - name: System info + run: | + set -x + whoami + id $(whoami) + free || vm_stat | perl -ne '/page size of (\d+)/ and $size=$1; + /Pages\s+([^:]+)[^\d]+(\d+)/ and printf("%-16s % 16.2f Mi\n", "$1:", $2 * $size / 1048576);' + df -h + - name: Build info + run: | + cat << 'END' + ref:${{github.ref}} + sha:${{github.sha}} + run_number:${{github.run_number}} + event_name:${{github.event_name}} + event.action:${{github.event.action}} + event.issue.number:${{ github.event.issue.number }} + END + - name: REF and SHA of commented PR to ENV + if: github.event.comment + run: > + curl -fsSL ${{github.event.issue.pull_request.url}} -H "Authorization: token ${{github.token}}" | jq -r ' + + "PR_REF="+.head.ref, + "PR_SHA="+.head.sha, + "PR_NUM="+(.number|tostring), + "PR_REPO="+.head.repo.full_name' >>$GITHUB_ENV + - name: Checkout head + uses: actions/checkout@v2 + with: + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} + - name: Determine dockertag + id: dockertag + env: + dockertag: ${{ hashFiles('docker/iroha-builder/**') }} + run: | + echo "::set-output name=dockertag::$dockertag" + echo >>$GITHUB_ENV dockertag=$dockertag + test -n "$DOCKERHUB_ORG" || { + echo ::error::"DOCKERHUB_ORG must contain value" + false + } + - name: Login to DockerHub + #if: ${{ secrets.DOCKERHUB_TOKEN != '' && secrets.DOCKERHUB_USERNAME != '' }} + id: docker_login + uses: docker/login-action@v1 + with: + #username: ${{ secrets.DOCKERHUB_USERNAME }} + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Log in to the Container registry GHCR + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Possible WARNING + if: ${{ steps.docker_login.outcome == 'skipped' }} + run: echo "::warning::DOCKERHUB_TOKEN and DOCKERHUB_USERNAME are empty. Will build but NOT push." + - name: Docker meta + id: meta + uses: docker/metadata-action@v3 + with: + images: ${{ env.DOCKERHUB_ORG }}/iroha-builder + tags: | + type=raw,value=${{env.dockertag}} + type=ref,event=branch + type=ref,event=pr + type=ref,event=tag + type=schedule + ## Docker image will be pushed with tags: + ## - hash of file Dockerfile.builder + ## - branchname, when branch is pushed + ## - pr-NUMBER, when pushed to PR + ## - git tag when tag is pushed + ## - schedule, see the docs + - uses: docker/metadata-action@v3 + name: Docker meta GHCR + id: meta_ghcr + with: + tags: | + type=raw,value=${{env.dockertag}} + type=ref,event=branch + type=ref,event=pr + type=ref,event=tag + type=schedule + ## Docker image will be pushed with tags: + ## - hash of file Dockerfile.builder + ## - branchname, when branch is pushed + ## - pr-NUMBER, when pushed to PR + ## - git tag when tag is pushed + ## - schedule, see the docs + + images: ghcr.io/${{ github.repository }}-builder + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{env.dockertag}} + restore-keys: ${{ runner.os }}-buildx- + - id: build_and_push + name: Build and push + uses: docker/build-push-action@v2 + with: + context: docker/iroha-builder/ + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new + push: ${{ steps.docker_login.outcome == 'success' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + # env: + # DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + # DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + - uses: docker/build-push-action@v2 + id: build_and_push_ghcr + name: Build and push to GHCR + with: + context: docker/iroha-builder/ + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new + push: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo == github.event.pull_request.base.repo }} + tags: ${{ steps.meta_ghcr.outputs.tags }} + labels: ${{ steps.meta_ghcr.outputs.labels }} + # env: + # DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + # DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + - # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache + - name: Check if dockertaghash exists in remote registry + id: dockertag_already + run: | + echo "::set-output name=container::$DOCKERHUB_ORG/iroha-builder:$dockertag" + docker pull "$DOCKERHUB_ORG/iroha-builder:$dockertag" + - name: Possible ERROR, Dockerfile edited, image was build, but seems not pushed, CANNOT PULL. + if: failure() + #if: ${{ steps.docker_login.outcome != 'success' || steps.build_and_push.outcome != 'success' }} + env: + container: ${{steps.dockertag_already.outputs.container}} + dockertag: ${{env.dockertag}} + run: | + cat </dev/null <<'END' + ${{ toJson(needs) }} + END + - env: + container: ${{needs.Docker-iroha-builder.outputs.container}} + run: test -n "$container" + - name: System info + run: | + set -x + whoami + id $(whoami) + free || vm_stat | perl -ne '/page size of (\d+)/ and $size=$1; + /Pages\s+([^:]+)[^\d]+(\d+)/ and printf("%-16s % 16.2f Mi\n", "$1:", $2 * $size / 1048576);' + df -h + - name: Build info + run: | + cat << 'END' + ref:${{github.ref}} + sha:${{github.sha}} + run_number:${{github.run_number}} + event_name:${{github.event_name}} + event.action:${{github.event.action}} + event.issue.number:${{ github.event.issue.number }} + END + - name: export CC,BuildType from matrix.buildspec + run: | + echo >>$GITHUB_ENV OS=$(echo ${{matrix.buildspec}} | awk '{print $1}') + echo >>$GITHUB_ENV CC_NAME=$(echo ${{matrix.buildspec}} | awk '{print $2}') + echo >>$GITHUB_ENV BuildType=$(echo ${{matrix.buildspec}} | awk '{print $3}') + features=$(echo ${{matrix.buildspec}} | awk '{print $4}') + case $features in + normal) echo >>$GITHUB_ENV CMAKE_USE=""; features= ;; + ursa) echo >>$GITHUB_ENV CMAKE_USE="-DUSE_LIBURSA=ON";; + burrow) echo >>$GITHUB_ENV CMAKE_USE="-DUSE_BURROW=ON";; + *) echo "::error::Unknown features '$features'"; false ;; + esac + echo >>$GITHUB_ENV features="$features" + echo >>$GITHUB_ENV skip_testing=$(echo ${{matrix.buildspec}} | grep -Fo skip_testing) + - name: REF and SHA of commented PR to ENV + if: github.event.comment + run: > + curl -fsSL ${{github.event.issue.pull_request.url}} -H "Authorization: token ${{github.token}}" | jq -r ' + + "PR_REF="+.head.ref, + "PR_SHA="+.head.sha, + "PR_NUM="+(.number|tostring), + "PR_REPO="+.head.repo.full_name' >>$GITHUB_ENV + - name: Checkout head + uses: actions/checkout@v2 + with: + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} + fetch-depth: 0 ## full history + - name: export CC and CXX + env: + CCACHE_PATH: /usr/lib/ccache + run: | + set -xeu #o pipefail + if test $CC_NAME = llvm + then CC=/usr/local/opt/llvm/bin/clang + else CC=$CC_NAME + fi + echo >>$GITHUB_ENV CC=$CC + echo >>$GITHUB_ENV CXX=$(echo $CC | sed -es,gcc,g++, -es,clang,clang++,) + echo >>$GITHUB_PATH $CCACHE_PATH + ls -lA $CCACHE_PATH + $(realpath $CCACHE_PATH/gcc) --show-config + echo >>$GITHUB_ENV _CCACHE_DIR=$($(realpath $CCACHE_PATH/gcc) --show-config | sed -nE 's,.*cache_dir = ,,p') + echo >>$GITHUB_ENV NPROC=$(nproc | awk '{printf("%.0f",$1*0.77)}') + echo >>$GITHUB_ENV HOME=$HOME + - name: Restore cache CCache + uses: actions/cache@v2 + with: + path: ${{ env._CCACHE_DIR }} + key: ${{runner.os}}-ccache-${{ github.event.pull_request.head.sha }} + restore-keys: ${{runner.os}}-ccache- + - run: ccache --show-stats | tee /tmp/ccache-stats + - ## Read the docs https://vcpkg.readthedocs.io/en/latest/users/binarycaching/ https://github.com/microsoft/vcpkg/blob/master/docs/users/binarycaching.md + name: Restore cache Vcpkg binarycache ## NOTE not useng NuGet because on ubuntu nuget needs mono of 433MB, unusable. + uses: actions/cache@v2 + with: + path: | + ${{env.HOME}}/.cache/vcpkg/archives + key: ${{runner.os}}-vcpkg-${{env.CC_NAME}}.${{ hashFiles('vcpkg/**') }} + restore-keys: ${{runner.os}}-vcpkg-${{env.CC_NAME}}. + - name: Build iroha vcpkg dependancies + run: ./vcpkg/build_iroha_deps.sh $PWD/vcpkg-build; test -f $PWD/vcpkg-build/scripts/buildsystems/vcpkg.cmake + ## Takes 48m16s on default GitHub runner with 2 cores + ## Takes 13m41s on self-hosted AWS EC2 c5.x4large + # ________________________________________________________ + # Executed in 32,08 mins fish external + # usr time 110,52 mins 0,24 millis 110,52 mins + # sys time 12,26 mins 1,34 millis 12,26 mins + # + # All requested packages are currently installed. + # ________________________________________________________ + # Executed in 3,17 secs fish external + # usr time 2,05 secs 128,00 micros 2,05 secs + # sys time 0,70 secs 575,00 micros 0,70 secs + - name: CMake configure + ## Takes 13s on regular GitHub runner + run: cmake -B build -DCMAKE_TOOLCHAIN_FILE=$PWD/vcpkg-build/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=${{ env.BuildType }} -GNinja $CMAKE_USE -DTESTING=$( test "$skip_testing" = skip_testing && echo OFF || echo ON ) -DBENCHMARKING=$( test "$skip_testing" = skip_testing && echo OFF || echo ON ) -DPACKAGE_DEB=ON + #-DCMAKE_VERBOSE_MAKEFILE=ON ## Note: use for debug + - name: CMake build + run: | + set -x + ## reduce memory usage to do not overflow + cmake --build build --config ${{ env.BuildType }} -- -j$(nproc | awk '{printf("%.0f",$1*0.77)}') + echo ::notice::"$(./build/bin/irohad --version)" + ## Debug takes 18m44s on regular GitHub runner + ## Debug takes 7m41s on self-hosted AWS EC2 c5.x4large + ## Release takes 2m58s on self-hosted AWS EC2 c5.x4large + - name: CPack (linux only) + run: cd build; cpack; ## cmake --build build --target package + - run: ccache --show-stats | diff --side-by-side /tmp/ccache-stats - ||true + - name: Show free space and disk usage + if: ${{ always() }} + run: | + df -h || true + - name: Generate artifact suffix depending on matrix to env.ARTIFACT_SUFFIX + run: | + set -x + cc=$(echo $CC_NAME | sed -Ee's,[-/],,g' ) + build_type=$(echo $BuildType | tr A-Z a-z | sed -E -es,debug,dbg, -es,release,rel, ) + test $build_type = dbg -o $build_type = rel + uses=$(echo "$features" | tr ' ' - | tr A-Z a-z) + _os=${OS:+-$OS} _cc=${cc:+-$cc} _build_type=${build_type:+-$build_type} _uses=${uses:+-$uses} + echo >>$GITHUB_ENV ARTIFACT_SUFFIX=$_os$_cc$_build_type$_uses + echo >>$GITHUB_ENV _uses_suffix=$_uses + echo >>$GITHUB_ENV _compiler_suffix=$(test $cc != gcc9 && echo $_cc) + echo >>$GITHUB_ENV _debug_suffix=$(test "$build_type" = dbg && echo -debug || true) + - name: Upload artifact irohad + uses: actions/upload-artifact@v2 + with: + name: irohad${{env.ARTIFACT_SUFFIX}} + path: | + build/bin/irohad + build/bin/iroha-cli + - name: Upload artifact iroha-deb + uses: actions/upload-artifact@v2 + with: + name: iroha-deb${{env.ARTIFACT_SUFFIX}} + path: | + build/*.deb + - if: ${{ false }} ## Maybe test in another job + name: Upload artifact tests + uses: actions/upload-artifact@v2 + with: + name: iroha-tests-ubuntu${{env.ARTIFACT_SUFFIX}} + path: | + build/test_bin/** + build/test_data/** + - timeout-minutes: 40 + if: env.skip_testing == '' + name: CTest + run: | + echo ::group::'boilerplate' + set -euo pipefail + if test $(uname) = Darwin ;then + ## This is a common portable solution, but Debian and Ubuntu have their own wrappers + initdb --locale=C --encoding=UTF-8 --username=postgres $PWD/postgres_database + postgres -D $PWD/postgres_database -p5432 2>&1 >/tmp/postgres.log & { sleep .3; kill -0 $!; } ## use pg_ctl no need & + else ## Debian or Ubuntu + ## Need to go debian-specific way because + ## initdb is not allowed to be run as root, but we need to run as root + ## because GitHub actions runners have much issues with permissions. + mkdir postgres_database && chown iroha-ci postgres_database + echo /usr/lib/postgresql/12/bin/initdb --locale=C --encoding=UTF-8 --username=postgres $PWD/postgres_database | su iroha-ci + echo /usr/lib/postgresql/12/bin/pg_ctl start -D $PWD/postgres_database --log=$PWD/postgres_database/log | su iroha-ci + # ## Need to go debian-specific way because + # ## initdb is not allowed to be run as root, but we need to run as root + # ## because GitHub actions runners have much issues with permissions. + # cat </etc/postgresql/12/main/pg_hba.conf + # # TYPE DATABASE USER ADDRESS METHOD + # local all all trust + # host all all 127.0.0.1/32 trust + # host all all ::1/128 trust + # local replication all trust + # host replication all 127.0.0.1/32 trust + # host replication all ::1/128 trust + # END + # pg_ctlcluster 12 main start ## Cluster 'main' exist by default + # #OR pg_createcluster -p 5432 --start 12 iroha -- --locale=C --encoding=UTF-8 --username=postgres + fi + cd build + + ## This is just a small lifehack to TEMPORARY allow some tests to fail + cat ../.github/TESTS_ALLOWED_TO_FAIL | sort -u >ALLOW_TO_FAIL || true + + if test -e ALLOW_TO_FAIL + then echo "::warning:: There are TESTS_ALLOWED_TO_FAIL: "$(cat ALLOW_TO_FAIL) + fi + + grep_failed_tests(){ + grep 'The following tests FAILED:' -A10000 "$@" | tail +2 #| cut -d- -f2 | cut -d' ' -f2 | sort + } + exclude_allowed_to_fail(){ + grep -Fvf ALLOW_TO_FAIL "$@" + } + only_allowed_to_fail(){ + grep -Ff ALLOW_TO_FAIL "$@" + } + list_to_line(){ + comma='' + while read N d name sta ;do + echo -n "$comma$N-$name$sta" + comma=', ' + done + } + echo ::endgroup:: + + ## Run module_* tests in parallel and others subsequently + ## Cathgories sorted in order of importancy + CTEST_CATHEGORIES=( module tool framework regression system integration ) + ## Add rest available cathgories + CTEST_CATHEGORIES+=( $( + ctest --show-only=json-v1 -R "^(module|tool|framework|regression|system|integration)" | + jq -r .tests[].name | + cut -f1 -d_ | + sort -u | + grep -Fvf <( printf '%s\n' ${CTEST_CATHEGORIES[@]} ) + ) + ) || true + CTEST_DEFAULT_timeout=80 + CTEST_module_timeout=120 CTEST_module_parallel=4 + CTEST_tool_timeout=200 + CTEST_integration_timeout=120 + CTEST_integration_args='--repeat until-pass:10' ## FIXME remove this hack + CTEST_system_args='--repeat until-pass:10' ## FIXME remove this hack + + for cathegory in ${CTEST_CATHEGORIES[@]} ;do + echo >&2 ::group::"$cathegory tests" + set -x + timeout_name=CTEST_${cathegory}_timeout; timeout=${!timeout_name:-$CTEST_DEFAULT_timeout} + parallel_name=CTEST_${cathegory}_parallel; parallel=${!parallel_name:-} + args_name=CTEST_${cathegory}_args; args=${!args_name:-} + ctest -R "^${cathegory}_" ${parallel:+--parallel $parallel} --output-on-failure --no-tests=error --timeout $timeout ${args:-} \ + | tee ctest_$cathegory.out \ + || true + set +x + echo >&2 ::endgroup:: + done + + tests_passed=true + for t in ${CTEST_CATHEGORIES[@]} ;do + f=ctest_$t.out + if a=$(grep_failed_tests $f | exclude_allowed_to_fail | list_to_line) ;then + echo "::error::The following $(echo $t | tr a-z A-Z) tests FAILED but not in list ALLOW_TO_FAIL: $a" + tests_passed=false + fi + if o=$(grep_failed_tests $f | only_allowed_to_fail | list_to_line) ;then + echo "::warning::The following $t tests FAILED and ALLOWED TO FAIL: $o" + fi + done + $tests_passed From f495cdaf3eafe03d87f6b18c6035c8ab4e2362e2 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Tue, 29 Mar 2022 14:32:26 +0300 Subject: [PATCH 002/130] Move to self-hosted runners Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 29e42425420..e2e8ec4e829 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -333,8 +333,8 @@ jobs: needs: - Docker-iroha-builder - generate_matrixes - #runs-on: [ self-hosted, Linux ] - runs-on: ubuntu-20.04 + runs-on: [ self-hosted, Linux ] + #runs-on: ubuntu-20.04 container: ## Container is taken from previous job image: &container_image ${{needs.Docker-iroha-builder.outputs.container}} options: --user root From 18ae787ad22a0cc0d069ef8c21140321ec4aaa7e Mon Sep 17 00:00:00 2001 From: safinsaf Date: Tue, 29 Mar 2022 14:36:00 +0300 Subject: [PATCH 003/130] Move to self-hosted runners Signed-off-by: safinsaf --- .github/workflows/build-iroha1-fork.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index dc2a8be67c3..c000ce7ee26 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -366,8 +366,8 @@ jobs: needs: - Docker-iroha-builder - generate_matrixes - #runs-on: [ self-hosted, Linux ] - runs-on: ubuntu-20.04 + runs-on: [self-hosted, Linux] + #runs-on: ubuntu-20.04 container: ## Container is taken from previous job image: ${{needs.Docker-iroha-builder.outputs.container}} options: --user root From e68dfd7ee261db646f76cfe36255e2b6e15490d9 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Tue, 29 Mar 2022 16:36:28 +0300 Subject: [PATCH 004/130] Add deploy steps Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 228 ++++- .github/workflows/build-iroha1-fork.yml | 1079 ++++++++++++++++++++++- 2 files changed, 1304 insertions(+), 3 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index e2e8ec4e829..f370a7a80a4 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -199,7 +199,6 @@ jobs: id: docker_login uses: docker/login-action@v1 with: - #username: ${{ secrets.DOCKERHUB_USERNAME }} username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - &step_docker_login_ghcr @@ -375,7 +374,7 @@ jobs: echo >>$GITHUB_ENV features="$features" echo >>$GITHUB_ENV skip_testing=$(echo ${{matrix.buildspec}} | grep -Fo skip_testing) - *step_detect_commented_pr - - &step_checkout_full + - &step_checkout_full_head <<: *step_checkout_head with: <<: *step_checkout_with_head @@ -603,3 +602,228 @@ jobs: fi done $tests_passed + + ## Just because release is built 2..3 times faster make it a different job + build-UR: + <<: *job_ubuntu + strategy: &strategy_ubuntu_release + fail-fast: false + matrix: ${{ fromJSON( needs.generate_matrixes.outputs.matrix_ubuntu_release ) }} + if: &if_ubuntu_release ${{ fromJSON( needs.generate_matrixes.outputs.matrix_ubuntu_release ).include[0] }} + + ## Just to align picture + prepare-macos-env: + needs: check_workflow_yaml_coressponds_to_src_yaml + runs-on: macos-latest + steps: + - *step_show_context + + build-M: + needs: + - prepare-macos-env + - generate_matrixes + runs-on: macos-latest #[ self-hosted, MacOS ] # + strategy: + fail-fast: false + matrix: ${{ fromJSON( needs.generate_matrixes.outputs.matrix_macos ) }} + if: ${{ fromJSON( needs.generate_matrixes.outputs.matrix_macos ).include[0] }} + defaults: + run: + shell: bash + steps: + - *step_show_context + - *step_system_info + - *step_build_info + - *step_env_from_buildspec + - + name: Homebrew + run: brew install cmake ninja coreutils ccache bash + ## Takes 22 seconds with default github runner + - + if: ${{ contains(env.CC_NAME, 'gcc-10') }} + name: Homebrew GCC + run: brew install gcc@10 + - + if: ${{ contains(env.CC_NAME, 'llvm') }} + name: Homebrew LLVM + run: brew install llvm + - + if: ${{ contains(env.features, 'burrow') }} + name: Install protoc-gen-go for -DUSE_BURROW=ON + run: | + go get github.com/golang/protobuf/protoc-gen-go + echo >>$GITHUB_PATH $HOME/go/bin + - *step_detect_commented_pr + - *step_checkout_full_head + - <<: *step_export_cxx + env: + <<: *step_export_cxx_env + CCACHE_PATH: /usr/local/opt/ccache/libexec + - *step_restore_ccache + - *step_store_ccache_stats + - *step_vcpkg_cache + - *step_vcpkg_build + - *step_cmake_configure + - *step_cmake_build + - *step_compare_ccache_stats + - *step_always_after_build + - *step_artifact_suffix + - <<: *step_artifact_irohad + with: + name: irohad-macos${{env.ARTIFACT_SUFFIX}} + path: *step_artifact_irohad_path + - *step_artifact_tests + - &step_brew_postgres + name: Install Postgres on MacOS + run: brew install postgresql + - <<: *step_ctest + timeout-minutes: 70 + + ## Just to align picture + prepare-windows-env: + needs: check_workflow_yaml_coressponds_to_src_yaml + runs-on: windows-latest + steps: + - *step_show_context + defaults: + run: + shell: bash + + build-W: + needs: + - prepare-windows-env + - generate_matrixes + runs-on: windows-latest + strategy: + fail-fast: false + matrix: ${{ fromJSON( needs.generate_matrixes.outputs.matrix_windows ) }} + if: ${{ false && ( fromJSON( needs.generate_matrixes.outputs.matrix_windows ).include[0] ) }} + defaults: + run: + shell: bash #pwsh + working-directory: &workdir 'C:\github\iroha' ## Use disk C: because D: is out of space + steps: + - name: Create working-directory, export WORKDIR + run: | + set -x + mkdir -p "$WORKDIR" + echo $PWD + echo >>$GITHUB_ENV WORKDIR="$WORKDIR" + working-directory: 'C:\' + env: { WORKDIR: *workdir } + - name: uname in bash + run: uname + shell: bash + - name: uname in [default] pwsh shell + run: uname + shell: pwsh + - &step_choco_install + name: Chocolatey install + run: choco install cmake ninja #ccache + - *step_checkout_full_head + - name: move to workdir + run: | + set -x + echo $PWD + shopt -s dotglob nullglob + mv -vf * -t "$WORKDIR" + working-directory: + #- *step_restore_ccache + #- *step_vcpkg_cache + - *step_vcpkg_build + - *step_cmake_configure + - *step_cmake_build + - *step_always_after_build + - name: Install Postgres on Windows + run: choco install postgresql + # - *step_ctest + + ## Build and publish docker image named 'hyperledger/iroha' with irohad and iroha tools inside. + ## The result docker image is pushed with tags :branch_name, :pr-NUMBER, :tag_name, + ## and :latest (for git-tags). + ## Those docker image tags could be extended with suffixes with compiler and build type like + ## -gcc10, -clang, -debug, -gcc10-debug. Like :latest-debug, :main-debug, :1.3.0-gcc10-debug. + ## Result image name could look like: hyperledger/iroha:pr-1117, hyperledger/iroha:nightly. + ## Note: image is push only when DockerHub login-token pair available - not to PRs from forks + docker-R: &job_docker_image_release + needs: + - build-UR + - generate_matrixes + runs-on: [ self-hosted, Linux ] #ubuntu-latest + # strategy: *strategy_ubuntu_release + # if: *if_ubuntu_release + strategy: + fail-fast: false + matrix: ${{ fromJSON( needs.generate_matrixes.outputs.matrix_dockerimage_release ) }} + if: ${{ fromJSON( needs.generate_matrixes.outputs.matrix_dockerimage_release ).include[0] }} + #env: &env_dockerhub_release + # <<: *env_dockerhub + # IMAGE_NAME: iroha + env: + IMAGE_NAME: iroha + steps: + - *step_show_context + - *step_system_info + - *step_build_info + - *step_env_from_buildspec + - *step_detect_commented_pr + - *step_checkout_head + - *step_artifact_suffix + - name: Download artifact + uses: actions/download-artifact@v2 + with: + name: iroha-deb${{env.ARTIFACT_SUFFIX}} + - name: Rename artifact debs + run: | + mv *iroha_shepherd.deb docker/release/iroha_shepherd.deb + mv *irohad.deb docker/release/iroha.deb + - <<: *step_docker_tag + env: + dockertag: ${{ hashFiles('docker/release/**') }} + - <<: *step_docker_meta + with: &step_docker_release_meta_with + images: | + ${{ env.DOCKERHUB_ORG }}/${{ env.IMAGE_NAME }}${{ env._uses_suffix }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=ref,event=tag + type=schedule + flavor: | + suffix=${{env._compiler_suffix}}${{env._debug_suffix}},onlatest=true + #maybetodo flavor: prefix=${{ env.USES_PREFIX }} ## In case creating repository hyperledger/iroha-burrow denied, Use tag prefix hyperledger/iroha:burrow-xxxx + - <<: *step_docker_meta_ghcr + with: + <<: *step_docker_release_meta_with + images: ghcr.io/${{ github.repository }}${{ env._uses_suffix }} + - *step_docker_login + - *step_docker_login_ghcr + - *step_warn_docker_no_push + - *step_docker_buildx + - <<: *step_docker_cache + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-release-${{env.dockertag}} + restore-keys: ${{ runner.os }}-buildx-release + - <<: *step_docker_build_and_push + with: + <<: *step_docker_build_and_push_with + context: docker/release/ + push: ${{ steps.docker_login.outcome == 'success' }} + - <<: *step_docker_build_and_push_ghcr + with: + <<: *step_docker_build_and_push_ghcr-with + context: docker/release/ + - *step_docker_move_cache + + docker-D: + <<: *job_docker_image_release + needs: + - build-UD + - generate_matrixes + # strategy: *strategy_ubuntu_debug + # if: *if_ubuntu_debug + strategy: + fail-fast: false + matrix: ${{ fromJSON( needs.generate_matrixes.outputs.matrix_dockerimage_debug ) }} + if: ${{ fromJSON( needs.generate_matrixes.outputs.matrix_dockerimage_debug ).include[0] }} \ No newline at end of file diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index c000ce7ee26..c8e17006f02 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -231,7 +231,6 @@ jobs: id: docker_login uses: docker/login-action@v1 with: - #username: ${{ secrets.DOCKERHUB_USERNAME }} username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Log in to the Container registry GHCR @@ -648,3 +647,1081 @@ jobs: fi done $tests_passed + ## Just because release is built 2..3 times faster make it a different job + build-UR: + needs: + - Docker-iroha-builder + - generate_matrixes + runs-on: [self-hosted, Linux] + #runs-on: ubuntu-20.04 + container: ## Container is taken from previous job + image: ${{needs.Docker-iroha-builder.outputs.container}} + options: --user root + defaults: + run: + shell: bash + steps: + - name: Show context + run: | + echo "::group::GitHub context" + cat <<'END' + ${{ toJson(github) }} + END + echo "::endgroup::" + echo "::group::GitHub needs" + cat <<'END' + ${{ toJson(needs) }} + END + echo "::endgroup::" + - name: Show needs + run: | + cat >/dev/null <<'END' + ${{ toJson(needs) }} + END + - env: + container: ${{needs.Docker-iroha-builder.outputs.container}} + run: test -n "$container" + - name: System info + run: | + set -x + whoami + id $(whoami) + free || vm_stat | perl -ne '/page size of (\d+)/ and $size=$1; + /Pages\s+([^:]+)[^\d]+(\d+)/ and printf("%-16s % 16.2f Mi\n", "$1:", $2 * $size / 1048576);' + df -h + - name: Build info + run: | + cat << 'END' + ref:${{github.ref}} + sha:${{github.sha}} + run_number:${{github.run_number}} + event_name:${{github.event_name}} + event.action:${{github.event.action}} + event.issue.number:${{ github.event.issue.number }} + END + - name: export CC,BuildType from matrix.buildspec + run: | + echo >>$GITHUB_ENV OS=$(echo ${{matrix.buildspec}} | awk '{print $1}') + echo >>$GITHUB_ENV CC_NAME=$(echo ${{matrix.buildspec}} | awk '{print $2}') + echo >>$GITHUB_ENV BuildType=$(echo ${{matrix.buildspec}} | awk '{print $3}') + features=$(echo ${{matrix.buildspec}} | awk '{print $4}') + case $features in + normal) echo >>$GITHUB_ENV CMAKE_USE=""; features= ;; + ursa) echo >>$GITHUB_ENV CMAKE_USE="-DUSE_LIBURSA=ON";; + burrow) echo >>$GITHUB_ENV CMAKE_USE="-DUSE_BURROW=ON";; + *) echo "::error::Unknown features '$features'"; false ;; + esac + echo >>$GITHUB_ENV features="$features" + echo >>$GITHUB_ENV skip_testing=$(echo ${{matrix.buildspec}} | grep -Fo skip_testing) + - name: REF and SHA of commented PR to ENV + if: github.event.comment + run: > + curl -fsSL ${{github.event.issue.pull_request.url}} -H "Authorization: token ${{github.token}}" | jq -r ' + + "PR_REF="+.head.ref, + "PR_SHA="+.head.sha, + "PR_NUM="+(.number|tostring), + "PR_REPO="+.head.repo.full_name' >>$GITHUB_ENV + - name: Checkout head + uses: actions/checkout@v2 + with: + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} + fetch-depth: 0 ## full history + - name: export CC and CXX + env: + CCACHE_PATH: /usr/lib/ccache + run: | + set -xeu #o pipefail + if test $CC_NAME = llvm + then CC=/usr/local/opt/llvm/bin/clang + else CC=$CC_NAME + fi + echo >>$GITHUB_ENV CC=$CC + echo >>$GITHUB_ENV CXX=$(echo $CC | sed -es,gcc,g++, -es,clang,clang++,) + echo >>$GITHUB_PATH $CCACHE_PATH + ls -lA $CCACHE_PATH + $(realpath $CCACHE_PATH/gcc) --show-config + echo >>$GITHUB_ENV _CCACHE_DIR=$($(realpath $CCACHE_PATH/gcc) --show-config | sed -nE 's,.*cache_dir = ,,p') + echo >>$GITHUB_ENV NPROC=$(nproc | awk '{printf("%.0f",$1*0.77)}') + echo >>$GITHUB_ENV HOME=$HOME + - name: Restore cache CCache + uses: actions/cache@v2 + with: + path: ${{ env._CCACHE_DIR }} + key: ${{runner.os}}-ccache-${{ github.event.pull_request.head.sha }} + restore-keys: ${{runner.os}}-ccache- + - run: ccache --show-stats | tee /tmp/ccache-stats + - ## Read the docs https://vcpkg.readthedocs.io/en/latest/users/binarycaching/ https://github.com/microsoft/vcpkg/blob/master/docs/users/binarycaching.md + name: Restore cache Vcpkg binarycache ## NOTE not useng NuGet because on ubuntu nuget needs mono of 433MB, unusable. + uses: actions/cache@v2 + with: + path: | + ${{env.HOME}}/.cache/vcpkg/archives + key: ${{runner.os}}-vcpkg-${{env.CC_NAME}}.${{ hashFiles('vcpkg/**') }} + restore-keys: ${{runner.os}}-vcpkg-${{env.CC_NAME}}. + - name: Build iroha vcpkg dependancies + run: ./vcpkg/build_iroha_deps.sh $PWD/vcpkg-build; test -f $PWD/vcpkg-build/scripts/buildsystems/vcpkg.cmake + ## Takes 48m16s on default GitHub runner with 2 cores + ## Takes 13m41s on self-hosted AWS EC2 c5.x4large + # ________________________________________________________ + # Executed in 32,08 mins fish external + # usr time 110,52 mins 0,24 millis 110,52 mins + # sys time 12,26 mins 1,34 millis 12,26 mins + # + # All requested packages are currently installed. + # ________________________________________________________ + # Executed in 3,17 secs fish external + # usr time 2,05 secs 128,00 micros 2,05 secs + # sys time 0,70 secs 575,00 micros 0,70 secs + - name: CMake configure + ## Takes 13s on regular GitHub runner + run: cmake -B build -DCMAKE_TOOLCHAIN_FILE=$PWD/vcpkg-build/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=${{ env.BuildType }} -GNinja $CMAKE_USE -DTESTING=$( test "$skip_testing" = skip_testing && echo OFF || echo ON ) -DBENCHMARKING=$( test "$skip_testing" = skip_testing && echo OFF || echo ON ) -DPACKAGE_DEB=ON + #-DCMAKE_VERBOSE_MAKEFILE=ON ## Note: use for debug + - name: CMake build + run: | + set -x + ## reduce memory usage to do not overflow + cmake --build build --config ${{ env.BuildType }} -- -j$(nproc | awk '{printf("%.0f",$1*0.77)}') + echo ::notice::"$(./build/bin/irohad --version)" + ## Debug takes 18m44s on regular GitHub runner + ## Debug takes 7m41s on self-hosted AWS EC2 c5.x4large + ## Release takes 2m58s on self-hosted AWS EC2 c5.x4large + - name: CPack (linux only) + run: cd build; cpack; ## cmake --build build --target package + - run: ccache --show-stats | diff --side-by-side /tmp/ccache-stats - ||true + - name: Show free space and disk usage + if: ${{ always() }} + run: | + df -h || true + - name: Generate artifact suffix depending on matrix to env.ARTIFACT_SUFFIX + run: | + set -x + cc=$(echo $CC_NAME | sed -Ee's,[-/],,g' ) + build_type=$(echo $BuildType | tr A-Z a-z | sed -E -es,debug,dbg, -es,release,rel, ) + test $build_type = dbg -o $build_type = rel + uses=$(echo "$features" | tr ' ' - | tr A-Z a-z) + _os=${OS:+-$OS} _cc=${cc:+-$cc} _build_type=${build_type:+-$build_type} _uses=${uses:+-$uses} + echo >>$GITHUB_ENV ARTIFACT_SUFFIX=$_os$_cc$_build_type$_uses + echo >>$GITHUB_ENV _uses_suffix=$_uses + echo >>$GITHUB_ENV _compiler_suffix=$(test $cc != gcc9 && echo $_cc) + echo >>$GITHUB_ENV _debug_suffix=$(test "$build_type" = dbg && echo -debug || true) + - name: Upload artifact irohad + uses: actions/upload-artifact@v2 + with: + name: irohad${{env.ARTIFACT_SUFFIX}} + path: | + build/bin/irohad + build/bin/iroha-cli + - name: Upload artifact iroha-deb + uses: actions/upload-artifact@v2 + with: + name: iroha-deb${{env.ARTIFACT_SUFFIX}} + path: | + build/*.deb + - if: ${{ false }} ## Maybe test in another job + name: Upload artifact tests + uses: actions/upload-artifact@v2 + with: + name: iroha-tests-ubuntu${{env.ARTIFACT_SUFFIX}} + path: | + build/test_bin/** + build/test_data/** + - timeout-minutes: 40 + if: env.skip_testing == '' + name: CTest + run: | + echo ::group::'boilerplate' + set -euo pipefail + if test $(uname) = Darwin ;then + ## This is a common portable solution, but Debian and Ubuntu have their own wrappers + initdb --locale=C --encoding=UTF-8 --username=postgres $PWD/postgres_database + postgres -D $PWD/postgres_database -p5432 2>&1 >/tmp/postgres.log & { sleep .3; kill -0 $!; } ## use pg_ctl no need & + else ## Debian or Ubuntu + ## Need to go debian-specific way because + ## initdb is not allowed to be run as root, but we need to run as root + ## because GitHub actions runners have much issues with permissions. + mkdir postgres_database && chown iroha-ci postgres_database + echo /usr/lib/postgresql/12/bin/initdb --locale=C --encoding=UTF-8 --username=postgres $PWD/postgres_database | su iroha-ci + echo /usr/lib/postgresql/12/bin/pg_ctl start -D $PWD/postgres_database --log=$PWD/postgres_database/log | su iroha-ci + # ## Need to go debian-specific way because + # ## initdb is not allowed to be run as root, but we need to run as root + # ## because GitHub actions runners have much issues with permissions. + # cat </etc/postgresql/12/main/pg_hba.conf + # # TYPE DATABASE USER ADDRESS METHOD + # local all all trust + # host all all 127.0.0.1/32 trust + # host all all ::1/128 trust + # local replication all trust + # host replication all 127.0.0.1/32 trust + # host replication all ::1/128 trust + # END + # pg_ctlcluster 12 main start ## Cluster 'main' exist by default + # #OR pg_createcluster -p 5432 --start 12 iroha -- --locale=C --encoding=UTF-8 --username=postgres + fi + cd build + + ## This is just a small lifehack to TEMPORARY allow some tests to fail + cat ../.github/TESTS_ALLOWED_TO_FAIL | sort -u >ALLOW_TO_FAIL || true + + if test -e ALLOW_TO_FAIL + then echo "::warning:: There are TESTS_ALLOWED_TO_FAIL: "$(cat ALLOW_TO_FAIL) + fi + + grep_failed_tests(){ + grep 'The following tests FAILED:' -A10000 "$@" | tail +2 #| cut -d- -f2 | cut -d' ' -f2 | sort + } + exclude_allowed_to_fail(){ + grep -Fvf ALLOW_TO_FAIL "$@" + } + only_allowed_to_fail(){ + grep -Ff ALLOW_TO_FAIL "$@" + } + list_to_line(){ + comma='' + while read N d name sta ;do + echo -n "$comma$N-$name$sta" + comma=', ' + done + } + echo ::endgroup:: + + ## Run module_* tests in parallel and others subsequently + ## Cathgories sorted in order of importancy + CTEST_CATHEGORIES=( module tool framework regression system integration ) + ## Add rest available cathgories + CTEST_CATHEGORIES+=( $( + ctest --show-only=json-v1 -R "^(module|tool|framework|regression|system|integration)" | + jq -r .tests[].name | + cut -f1 -d_ | + sort -u | + grep -Fvf <( printf '%s\n' ${CTEST_CATHEGORIES[@]} ) + ) + ) || true + CTEST_DEFAULT_timeout=80 + CTEST_module_timeout=120 CTEST_module_parallel=4 + CTEST_tool_timeout=200 + CTEST_integration_timeout=120 + CTEST_integration_args='--repeat until-pass:10' ## FIXME remove this hack + CTEST_system_args='--repeat until-pass:10' ## FIXME remove this hack + + for cathegory in ${CTEST_CATHEGORIES[@]} ;do + echo >&2 ::group::"$cathegory tests" + set -x + timeout_name=CTEST_${cathegory}_timeout; timeout=${!timeout_name:-$CTEST_DEFAULT_timeout} + parallel_name=CTEST_${cathegory}_parallel; parallel=${!parallel_name:-} + args_name=CTEST_${cathegory}_args; args=${!args_name:-} + ctest -R "^${cathegory}_" ${parallel:+--parallel $parallel} --output-on-failure --no-tests=error --timeout $timeout ${args:-} \ + | tee ctest_$cathegory.out \ + || true + set +x + echo >&2 ::endgroup:: + done + + tests_passed=true + for t in ${CTEST_CATHEGORIES[@]} ;do + f=ctest_$t.out + if a=$(grep_failed_tests $f | exclude_allowed_to_fail | list_to_line) ;then + echo "::error::The following $(echo $t | tr a-z A-Z) tests FAILED but not in list ALLOW_TO_FAIL: $a" + tests_passed=false + fi + if o=$(grep_failed_tests $f | only_allowed_to_fail | list_to_line) ;then + echo "::warning::The following $t tests FAILED and ALLOWED TO FAIL: $o" + fi + done + $tests_passed + strategy: + fail-fast: false + matrix: ${{ fromJSON( needs.generate_matrixes.outputs.matrix_ubuntu_release ) }} + if: ${{ fromJSON( needs.generate_matrixes.outputs.matrix_ubuntu_release ).include[0] }} + ## Just to align picture + prepare-macos-env: + needs: check_workflow_yaml_coressponds_to_src_yaml + runs-on: macos-latest + steps: + - name: Show context + run: | + echo "::group::GitHub context" + cat <<'END' + ${{ toJson(github) }} + END + echo "::endgroup::" + echo "::group::GitHub needs" + cat <<'END' + ${{ toJson(needs) }} + END + echo "::endgroup::" + build-M: + needs: + - prepare-macos-env + - generate_matrixes + runs-on: macos-latest #[ self-hosted, MacOS ] # + strategy: + fail-fast: false + matrix: ${{ fromJSON( needs.generate_matrixes.outputs.matrix_macos ) }} + if: ${{ fromJSON( needs.generate_matrixes.outputs.matrix_macos ).include[0] }} + defaults: + run: + shell: bash + steps: + - name: Show context + run: | + echo "::group::GitHub context" + cat <<'END' + ${{ toJson(github) }} + END + echo "::endgroup::" + echo "::group::GitHub needs" + cat <<'END' + ${{ toJson(needs) }} + END + echo "::endgroup::" + - name: System info + run: | + set -x + whoami + id $(whoami) + free || vm_stat | perl -ne '/page size of (\d+)/ and $size=$1; + /Pages\s+([^:]+)[^\d]+(\d+)/ and printf("%-16s % 16.2f Mi\n", "$1:", $2 * $size / 1048576);' + df -h + - name: Build info + run: | + cat << 'END' + ref:${{github.ref}} + sha:${{github.sha}} + run_number:${{github.run_number}} + event_name:${{github.event_name}} + event.action:${{github.event.action}} + event.issue.number:${{ github.event.issue.number }} + END + - name: export CC,BuildType from matrix.buildspec + run: | + echo >>$GITHUB_ENV OS=$(echo ${{matrix.buildspec}} | awk '{print $1}') + echo >>$GITHUB_ENV CC_NAME=$(echo ${{matrix.buildspec}} | awk '{print $2}') + echo >>$GITHUB_ENV BuildType=$(echo ${{matrix.buildspec}} | awk '{print $3}') + features=$(echo ${{matrix.buildspec}} | awk '{print $4}') + case $features in + normal) echo >>$GITHUB_ENV CMAKE_USE=""; features= ;; + ursa) echo >>$GITHUB_ENV CMAKE_USE="-DUSE_LIBURSA=ON";; + burrow) echo >>$GITHUB_ENV CMAKE_USE="-DUSE_BURROW=ON";; + *) echo "::error::Unknown features '$features'"; false ;; + esac + echo >>$GITHUB_ENV features="$features" + echo >>$GITHUB_ENV skip_testing=$(echo ${{matrix.buildspec}} | grep -Fo skip_testing) + - name: Homebrew + run: brew install cmake ninja coreutils ccache bash + ## Takes 22 seconds with default github runner + - if: ${{ contains(env.CC_NAME, 'gcc-10') }} + name: Homebrew GCC + run: brew install gcc@10 + - if: ${{ contains(env.CC_NAME, 'llvm') }} + name: Homebrew LLVM + run: brew install llvm + - if: ${{ contains(env.features, 'burrow') }} + name: Install protoc-gen-go for -DUSE_BURROW=ON + run: | + go get github.com/golang/protobuf/protoc-gen-go + echo >>$GITHUB_PATH $HOME/go/bin + - name: REF and SHA of commented PR to ENV + if: github.event.comment + run: > + curl -fsSL ${{github.event.issue.pull_request.url}} -H "Authorization: token ${{github.token}}" | jq -r ' + + "PR_REF="+.head.ref, + "PR_SHA="+.head.sha, + "PR_NUM="+(.number|tostring), + "PR_REPO="+.head.repo.full_name' >>$GITHUB_ENV + - name: Checkout head + uses: actions/checkout@v2 + with: + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} + fetch-depth: 0 ## full history + - name: export CC and CXX + run: | + set -xeu #o pipefail + if test $CC_NAME = llvm + then CC=/usr/local/opt/llvm/bin/clang + else CC=$CC_NAME + fi + echo >>$GITHUB_ENV CC=$CC + echo >>$GITHUB_ENV CXX=$(echo $CC | sed -es,gcc,g++, -es,clang,clang++,) + echo >>$GITHUB_PATH $CCACHE_PATH + ls -lA $CCACHE_PATH + $(realpath $CCACHE_PATH/gcc) --show-config + echo >>$GITHUB_ENV _CCACHE_DIR=$($(realpath $CCACHE_PATH/gcc) --show-config | sed -nE 's,.*cache_dir = ,,p') + echo >>$GITHUB_ENV NPROC=$(nproc | awk '{printf("%.0f",$1*0.77)}') + echo >>$GITHUB_ENV HOME=$HOME + env: + CCACHE_PATH: /usr/local/opt/ccache/libexec + - name: Restore cache CCache + uses: actions/cache@v2 + with: + path: ${{ env._CCACHE_DIR }} + key: ${{runner.os}}-ccache-${{ github.event.pull_request.head.sha }} + restore-keys: ${{runner.os}}-ccache- + - run: ccache --show-stats | tee /tmp/ccache-stats + - ## Read the docs https://vcpkg.readthedocs.io/en/latest/users/binarycaching/ https://github.com/microsoft/vcpkg/blob/master/docs/users/binarycaching.md + name: Restore cache Vcpkg binarycache ## NOTE not useng NuGet because on ubuntu nuget needs mono of 433MB, unusable. + uses: actions/cache@v2 + with: + path: | + ${{env.HOME}}/.cache/vcpkg/archives + key: ${{runner.os}}-vcpkg-${{env.CC_NAME}}.${{ hashFiles('vcpkg/**') }} + restore-keys: ${{runner.os}}-vcpkg-${{env.CC_NAME}}. + - name: Build iroha vcpkg dependancies + run: ./vcpkg/build_iroha_deps.sh $PWD/vcpkg-build; test -f $PWD/vcpkg-build/scripts/buildsystems/vcpkg.cmake + ## Takes 48m16s on default GitHub runner with 2 cores + ## Takes 13m41s on self-hosted AWS EC2 c5.x4large + # ________________________________________________________ + # Executed in 32,08 mins fish external + # usr time 110,52 mins 0,24 millis 110,52 mins + # sys time 12,26 mins 1,34 millis 12,26 mins + # + # All requested packages are currently installed. + # ________________________________________________________ + # Executed in 3,17 secs fish external + # usr time 2,05 secs 128,00 micros 2,05 secs + # sys time 0,70 secs 575,00 micros 0,70 secs + - name: CMake configure + ## Takes 13s on regular GitHub runner + run: cmake -B build -DCMAKE_TOOLCHAIN_FILE=$PWD/vcpkg-build/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=${{ env.BuildType }} -GNinja $CMAKE_USE -DTESTING=$( test "$skip_testing" = skip_testing && echo OFF || echo ON ) -DBENCHMARKING=$( test "$skip_testing" = skip_testing && echo OFF || echo ON ) -DPACKAGE_DEB=ON + #-DCMAKE_VERBOSE_MAKEFILE=ON ## Note: use for debug + - name: CMake build + run: | + set -x + ## reduce memory usage to do not overflow + cmake --build build --config ${{ env.BuildType }} -- -j$(nproc | awk '{printf("%.0f",$1*0.77)}') + echo ::notice::"$(./build/bin/irohad --version)" + ## Debug takes 18m44s on regular GitHub runner + ## Debug takes 7m41s on self-hosted AWS EC2 c5.x4large + ## Release takes 2m58s on self-hosted AWS EC2 c5.x4large + - run: ccache --show-stats | diff --side-by-side /tmp/ccache-stats - ||true + - name: Show free space and disk usage + if: ${{ always() }} + run: | + df -h || true + - name: Generate artifact suffix depending on matrix to env.ARTIFACT_SUFFIX + run: | + set -x + cc=$(echo $CC_NAME | sed -Ee's,[-/],,g' ) + build_type=$(echo $BuildType | tr A-Z a-z | sed -E -es,debug,dbg, -es,release,rel, ) + test $build_type = dbg -o $build_type = rel + uses=$(echo "$features" | tr ' ' - | tr A-Z a-z) + _os=${OS:+-$OS} _cc=${cc:+-$cc} _build_type=${build_type:+-$build_type} _uses=${uses:+-$uses} + echo >>$GITHUB_ENV ARTIFACT_SUFFIX=$_os$_cc$_build_type$_uses + echo >>$GITHUB_ENV _uses_suffix=$_uses + echo >>$GITHUB_ENV _compiler_suffix=$(test $cc != gcc9 && echo $_cc) + echo >>$GITHUB_ENV _debug_suffix=$(test "$build_type" = dbg && echo -debug || true) + - name: Upload artifact irohad + uses: actions/upload-artifact@v2 + with: + name: irohad-macos${{env.ARTIFACT_SUFFIX}} + path: | + build/bin/irohad + build/bin/iroha-cli + - if: ${{ false }} ## Maybe test in another job + name: Upload artifact tests + uses: actions/upload-artifact@v2 + with: + name: iroha-tests-ubuntu${{env.ARTIFACT_SUFFIX}} + path: | + build/test_bin/** + build/test_data/** + - name: Install Postgres on MacOS + run: brew install postgresql + - if: env.skip_testing == '' + name: CTest + run: | + echo ::group::'boilerplate' + set -euo pipefail + if test $(uname) = Darwin ;then + ## This is a common portable solution, but Debian and Ubuntu have their own wrappers + initdb --locale=C --encoding=UTF-8 --username=postgres $PWD/postgres_database + postgres -D $PWD/postgres_database -p5432 2>&1 >/tmp/postgres.log & { sleep .3; kill -0 $!; } ## use pg_ctl no need & + else ## Debian or Ubuntu + ## Need to go debian-specific way because + ## initdb is not allowed to be run as root, but we need to run as root + ## because GitHub actions runners have much issues with permissions. + mkdir postgres_database && chown iroha-ci postgres_database + echo /usr/lib/postgresql/12/bin/initdb --locale=C --encoding=UTF-8 --username=postgres $PWD/postgres_database | su iroha-ci + echo /usr/lib/postgresql/12/bin/pg_ctl start -D $PWD/postgres_database --log=$PWD/postgres_database/log | su iroha-ci + # ## Need to go debian-specific way because + # ## initdb is not allowed to be run as root, but we need to run as root + # ## because GitHub actions runners have much issues with permissions. + # cat </etc/postgresql/12/main/pg_hba.conf + # # TYPE DATABASE USER ADDRESS METHOD + # local all all trust + # host all all 127.0.0.1/32 trust + # host all all ::1/128 trust + # local replication all trust + # host replication all 127.0.0.1/32 trust + # host replication all ::1/128 trust + # END + # pg_ctlcluster 12 main start ## Cluster 'main' exist by default + # #OR pg_createcluster -p 5432 --start 12 iroha -- --locale=C --encoding=UTF-8 --username=postgres + fi + cd build + + ## This is just a small lifehack to TEMPORARY allow some tests to fail + cat ../.github/TESTS_ALLOWED_TO_FAIL | sort -u >ALLOW_TO_FAIL || true + + if test -e ALLOW_TO_FAIL + then echo "::warning:: There are TESTS_ALLOWED_TO_FAIL: "$(cat ALLOW_TO_FAIL) + fi + + grep_failed_tests(){ + grep 'The following tests FAILED:' -A10000 "$@" | tail +2 #| cut -d- -f2 | cut -d' ' -f2 | sort + } + exclude_allowed_to_fail(){ + grep -Fvf ALLOW_TO_FAIL "$@" + } + only_allowed_to_fail(){ + grep -Ff ALLOW_TO_FAIL "$@" + } + list_to_line(){ + comma='' + while read N d name sta ;do + echo -n "$comma$N-$name$sta" + comma=', ' + done + } + echo ::endgroup:: + + ## Run module_* tests in parallel and others subsequently + ## Cathgories sorted in order of importancy + CTEST_CATHEGORIES=( module tool framework regression system integration ) + ## Add rest available cathgories + CTEST_CATHEGORIES+=( $( + ctest --show-only=json-v1 -R "^(module|tool|framework|regression|system|integration)" | + jq -r .tests[].name | + cut -f1 -d_ | + sort -u | + grep -Fvf <( printf '%s\n' ${CTEST_CATHEGORIES[@]} ) + ) + ) || true + CTEST_DEFAULT_timeout=80 + CTEST_module_timeout=120 CTEST_module_parallel=4 + CTEST_tool_timeout=200 + CTEST_integration_timeout=120 + CTEST_integration_args='--repeat until-pass:10' ## FIXME remove this hack + CTEST_system_args='--repeat until-pass:10' ## FIXME remove this hack + + for cathegory in ${CTEST_CATHEGORIES[@]} ;do + echo >&2 ::group::"$cathegory tests" + set -x + timeout_name=CTEST_${cathegory}_timeout; timeout=${!timeout_name:-$CTEST_DEFAULT_timeout} + parallel_name=CTEST_${cathegory}_parallel; parallel=${!parallel_name:-} + args_name=CTEST_${cathegory}_args; args=${!args_name:-} + ctest -R "^${cathegory}_" ${parallel:+--parallel $parallel} --output-on-failure --no-tests=error --timeout $timeout ${args:-} \ + | tee ctest_$cathegory.out \ + || true + set +x + echo >&2 ::endgroup:: + done + + tests_passed=true + for t in ${CTEST_CATHEGORIES[@]} ;do + f=ctest_$t.out + if a=$(grep_failed_tests $f | exclude_allowed_to_fail | list_to_line) ;then + echo "::error::The following $(echo $t | tr a-z A-Z) tests FAILED but not in list ALLOW_TO_FAIL: $a" + tests_passed=false + fi + if o=$(grep_failed_tests $f | only_allowed_to_fail | list_to_line) ;then + echo "::warning::The following $t tests FAILED and ALLOWED TO FAIL: $o" + fi + done + $tests_passed + timeout-minutes: 70 + ## Just to align picture + prepare-windows-env: + needs: check_workflow_yaml_coressponds_to_src_yaml + runs-on: windows-latest + steps: + - name: Show context + run: | + echo "::group::GitHub context" + cat <<'END' + ${{ toJson(github) }} + END + echo "::endgroup::" + echo "::group::GitHub needs" + cat <<'END' + ${{ toJson(needs) }} + END + echo "::endgroup::" + defaults: + run: + shell: bash + build-W: + needs: + - prepare-windows-env + - generate_matrixes + runs-on: windows-latest + strategy: + fail-fast: false + matrix: ${{ fromJSON( needs.generate_matrixes.outputs.matrix_windows ) }} + if: ${{ false && ( fromJSON( needs.generate_matrixes.outputs.matrix_windows ).include[0] ) }} + defaults: + run: + shell: bash #pwsh + working-directory: 'C:\github\iroha' ## Use disk C: because D: is out of space + steps: + - name: Create working-directory, export WORKDIR + run: | + set -x + mkdir -p "$WORKDIR" + echo $PWD + echo >>$GITHUB_ENV WORKDIR="$WORKDIR" + working-directory: 'C:\' + env: {WORKDIR: 'C:\github\iroha'} + - name: uname in bash + run: uname + shell: bash + - name: uname in [default] pwsh shell + run: uname + shell: pwsh + - name: Chocolatey install + run: choco install cmake ninja #ccache + - name: Checkout head + uses: actions/checkout@v2 + with: + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} + fetch-depth: 0 ## full history + - name: move to workdir + run: | + set -x + echo $PWD + shopt -s dotglob nullglob + mv -vf * -t "$WORKDIR" + working-directory: + #- *step_restore_ccache + #- *step_vcpkg_cache + - name: Build iroha vcpkg dependancies + run: ./vcpkg/build_iroha_deps.sh $PWD/vcpkg-build; test -f $PWD/vcpkg-build/scripts/buildsystems/vcpkg.cmake + ## Takes 48m16s on default GitHub runner with 2 cores + ## Takes 13m41s on self-hosted AWS EC2 c5.x4large + # ________________________________________________________ + # Executed in 32,08 mins fish external + # usr time 110,52 mins 0,24 millis 110,52 mins + # sys time 12,26 mins 1,34 millis 12,26 mins + # + # All requested packages are currently installed. + # ________________________________________________________ + # Executed in 3,17 secs fish external + # usr time 2,05 secs 128,00 micros 2,05 secs + # sys time 0,70 secs 575,00 micros 0,70 secs + - name: CMake configure + ## Takes 13s on regular GitHub runner + run: cmake -B build -DCMAKE_TOOLCHAIN_FILE=$PWD/vcpkg-build/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=${{ env.BuildType }} -GNinja $CMAKE_USE -DTESTING=$( test "$skip_testing" = skip_testing && echo OFF || echo ON ) -DBENCHMARKING=$( test "$skip_testing" = skip_testing && echo OFF || echo ON ) -DPACKAGE_DEB=ON + #-DCMAKE_VERBOSE_MAKEFILE=ON ## Note: use for debug + - name: CMake build + run: | + set -x + ## reduce memory usage to do not overflow + cmake --build build --config ${{ env.BuildType }} -- -j$(nproc | awk '{printf("%.0f",$1*0.77)}') + echo ::notice::"$(./build/bin/irohad --version)" + ## Debug takes 18m44s on regular GitHub runner + ## Debug takes 7m41s on self-hosted AWS EC2 c5.x4large + ## Release takes 2m58s on self-hosted AWS EC2 c5.x4large + - name: Show free space and disk usage + if: ${{ always() }} + run: | + df -h || true + - name: Install Postgres on Windows + run: choco install postgresql + # - *step_ctest + ## Build and publish docker image named 'hyperledger/iroha' with irohad and iroha tools inside. + ## The result docker image is pushed with tags :branch_name, :pr-NUMBER, :tag_name, + ## and :latest (for git-tags). + ## Those docker image tags could be extended with suffixes with compiler and build type like + ## -gcc10, -clang, -debug, -gcc10-debug. Like :latest-debug, :main-debug, :1.3.0-gcc10-debug. + ## Result image name could look like: hyperledger/iroha:pr-1117, hyperledger/iroha:nightly. + ## Note: image is push only when DockerHub login-token pair available - not to PRs from forks + docker-R: + needs: + - build-UR + - generate_matrixes + runs-on: [self-hosted, Linux] #ubuntu-latest + # strategy: *strategy_ubuntu_release + # if: *if_ubuntu_release + strategy: + fail-fast: false + matrix: ${{ fromJSON( needs.generate_matrixes.outputs.matrix_dockerimage_release ) }} + if: ${{ fromJSON( needs.generate_matrixes.outputs.matrix_dockerimage_release ).include[0] }} + #env: &env_dockerhub_release + # <<: *env_dockerhub + # IMAGE_NAME: iroha + env: + IMAGE_NAME: iroha + steps: + - name: Show context + run: | + echo "::group::GitHub context" + cat <<'END' + ${{ toJson(github) }} + END + echo "::endgroup::" + echo "::group::GitHub needs" + cat <<'END' + ${{ toJson(needs) }} + END + echo "::endgroup::" + - name: System info + run: | + set -x + whoami + id $(whoami) + free || vm_stat | perl -ne '/page size of (\d+)/ and $size=$1; + /Pages\s+([^:]+)[^\d]+(\d+)/ and printf("%-16s % 16.2f Mi\n", "$1:", $2 * $size / 1048576);' + df -h + - name: Build info + run: | + cat << 'END' + ref:${{github.ref}} + sha:${{github.sha}} + run_number:${{github.run_number}} + event_name:${{github.event_name}} + event.action:${{github.event.action}} + event.issue.number:${{ github.event.issue.number }} + END + - name: export CC,BuildType from matrix.buildspec + run: | + echo >>$GITHUB_ENV OS=$(echo ${{matrix.buildspec}} | awk '{print $1}') + echo >>$GITHUB_ENV CC_NAME=$(echo ${{matrix.buildspec}} | awk '{print $2}') + echo >>$GITHUB_ENV BuildType=$(echo ${{matrix.buildspec}} | awk '{print $3}') + features=$(echo ${{matrix.buildspec}} | awk '{print $4}') + case $features in + normal) echo >>$GITHUB_ENV CMAKE_USE=""; features= ;; + ursa) echo >>$GITHUB_ENV CMAKE_USE="-DUSE_LIBURSA=ON";; + burrow) echo >>$GITHUB_ENV CMAKE_USE="-DUSE_BURROW=ON";; + *) echo "::error::Unknown features '$features'"; false ;; + esac + echo >>$GITHUB_ENV features="$features" + echo >>$GITHUB_ENV skip_testing=$(echo ${{matrix.buildspec}} | grep -Fo skip_testing) + - name: REF and SHA of commented PR to ENV + if: github.event.comment + run: > + curl -fsSL ${{github.event.issue.pull_request.url}} -H "Authorization: token ${{github.token}}" | jq -r ' + + "PR_REF="+.head.ref, + "PR_SHA="+.head.sha, + "PR_NUM="+(.number|tostring), + "PR_REPO="+.head.repo.full_name' >>$GITHUB_ENV + - name: Checkout head + uses: actions/checkout@v2 + with: + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} + - name: Generate artifact suffix depending on matrix to env.ARTIFACT_SUFFIX + run: | + set -x + cc=$(echo $CC_NAME | sed -Ee's,[-/],,g' ) + build_type=$(echo $BuildType | tr A-Z a-z | sed -E -es,debug,dbg, -es,release,rel, ) + test $build_type = dbg -o $build_type = rel + uses=$(echo "$features" | tr ' ' - | tr A-Z a-z) + _os=${OS:+-$OS} _cc=${cc:+-$cc} _build_type=${build_type:+-$build_type} _uses=${uses:+-$uses} + echo >>$GITHUB_ENV ARTIFACT_SUFFIX=$_os$_cc$_build_type$_uses + echo >>$GITHUB_ENV _uses_suffix=$_uses + echo >>$GITHUB_ENV _compiler_suffix=$(test $cc != gcc9 && echo $_cc) + echo >>$GITHUB_ENV _debug_suffix=$(test "$build_type" = dbg && echo -debug || true) + - name: Download artifact + uses: actions/download-artifact@v2 + with: + name: iroha-deb${{env.ARTIFACT_SUFFIX}} + - name: Rename artifact debs + run: | + mv *iroha_shepherd.deb docker/release/iroha_shepherd.deb + mv *irohad.deb docker/release/iroha.deb + - name: Determine dockertag + id: dockertag + run: | + echo "::set-output name=dockertag::$dockertag" + echo >>$GITHUB_ENV dockertag=$dockertag + test -n "$DOCKERHUB_ORG" || { + echo ::error::"DOCKERHUB_ORG must contain value" + false + } + env: + dockertag: ${{ hashFiles('docker/release/**') }} + - name: Docker meta + id: meta + uses: docker/metadata-action@v3 + with: + images: | + ${{ env.DOCKERHUB_ORG }}/${{ env.IMAGE_NAME }}${{ env._uses_suffix }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=ref,event=tag + type=schedule + flavor: | + suffix=${{env._compiler_suffix}}${{env._debug_suffix}},onlatest=true + #maybetodo flavor: prefix=${{ env.USES_PREFIX }} ## In case creating repository hyperledger/iroha-burrow denied, Use tag prefix hyperledger/iroha:burrow-xxxx + - uses: docker/metadata-action@v3 + name: Docker meta GHCR + id: meta_ghcr + with: + tags: | + type=ref,event=branch + type=ref,event=pr + type=ref,event=tag + type=schedule + flavor: | + suffix=${{env._compiler_suffix}}${{env._debug_suffix}},onlatest=true + #maybetodo flavor: prefix=${{ env.USES_PREFIX }} ## In case creating repository hyperledger/iroha-burrow denied, Use tag prefix hyperledger/iroha:burrow-xxxx + + images: ghcr.io/${{ github.repository }}${{ env._uses_suffix }} + - name: Login to DockerHub + #if: ${{ secrets.DOCKERHUB_TOKEN != '' && secrets.DOCKERHUB_USERNAME != '' }} + id: docker_login + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Log in to the Container registry GHCR + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Possible WARNING + if: ${{ steps.docker_login.outcome == 'skipped' }} + run: echo "::warning::DOCKERHUB_TOKEN and DOCKERHUB_USERNAME are empty. Will build but NOT push." + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-release-${{env.dockertag}} + restore-keys: ${{ runner.os }}-buildx-release + - id: build_and_push + name: Build and push + uses: docker/build-push-action@v2 + with: + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + # env: + # DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + # DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + + context: docker/release/ + push: ${{ steps.docker_login.outcome == 'success' }} + - uses: docker/build-push-action@v2 + id: build_and_push_ghcr + name: Build and push to GHCR + with: + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new + push: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo == github.event.pull_request.base.repo }} + tags: ${{ steps.meta_ghcr.outputs.tags }} + labels: ${{ steps.meta_ghcr.outputs.labels }} + # env: + # DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + # DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + + context: docker/release/ + - # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache + docker-D: + runs-on: [self-hosted, Linux] #ubuntu-latest + #env: &env_dockerhub_release + # <<: *env_dockerhub + # IMAGE_NAME: iroha + env: + IMAGE_NAME: iroha + steps: + - name: Show context + run: | + echo "::group::GitHub context" + cat <<'END' + ${{ toJson(github) }} + END + echo "::endgroup::" + echo "::group::GitHub needs" + cat <<'END' + ${{ toJson(needs) }} + END + echo "::endgroup::" + - name: System info + run: | + set -x + whoami + id $(whoami) + free || vm_stat | perl -ne '/page size of (\d+)/ and $size=$1; + /Pages\s+([^:]+)[^\d]+(\d+)/ and printf("%-16s % 16.2f Mi\n", "$1:", $2 * $size / 1048576);' + df -h + - name: Build info + run: | + cat << 'END' + ref:${{github.ref}} + sha:${{github.sha}} + run_number:${{github.run_number}} + event_name:${{github.event_name}} + event.action:${{github.event.action}} + event.issue.number:${{ github.event.issue.number }} + END + - name: export CC,BuildType from matrix.buildspec + run: | + echo >>$GITHUB_ENV OS=$(echo ${{matrix.buildspec}} | awk '{print $1}') + echo >>$GITHUB_ENV CC_NAME=$(echo ${{matrix.buildspec}} | awk '{print $2}') + echo >>$GITHUB_ENV BuildType=$(echo ${{matrix.buildspec}} | awk '{print $3}') + features=$(echo ${{matrix.buildspec}} | awk '{print $4}') + case $features in + normal) echo >>$GITHUB_ENV CMAKE_USE=""; features= ;; + ursa) echo >>$GITHUB_ENV CMAKE_USE="-DUSE_LIBURSA=ON";; + burrow) echo >>$GITHUB_ENV CMAKE_USE="-DUSE_BURROW=ON";; + *) echo "::error::Unknown features '$features'"; false ;; + esac + echo >>$GITHUB_ENV features="$features" + echo >>$GITHUB_ENV skip_testing=$(echo ${{matrix.buildspec}} | grep -Fo skip_testing) + - name: REF and SHA of commented PR to ENV + if: github.event.comment + run: > + curl -fsSL ${{github.event.issue.pull_request.url}} -H "Authorization: token ${{github.token}}" | jq -r ' + + "PR_REF="+.head.ref, + "PR_SHA="+.head.sha, + "PR_NUM="+(.number|tostring), + "PR_REPO="+.head.repo.full_name' >>$GITHUB_ENV + - name: Checkout head + uses: actions/checkout@v2 + with: + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} + - name: Generate artifact suffix depending on matrix to env.ARTIFACT_SUFFIX + run: | + set -x + cc=$(echo $CC_NAME | sed -Ee's,[-/],,g' ) + build_type=$(echo $BuildType | tr A-Z a-z | sed -E -es,debug,dbg, -es,release,rel, ) + test $build_type = dbg -o $build_type = rel + uses=$(echo "$features" | tr ' ' - | tr A-Z a-z) + _os=${OS:+-$OS} _cc=${cc:+-$cc} _build_type=${build_type:+-$build_type} _uses=${uses:+-$uses} + echo >>$GITHUB_ENV ARTIFACT_SUFFIX=$_os$_cc$_build_type$_uses + echo >>$GITHUB_ENV _uses_suffix=$_uses + echo >>$GITHUB_ENV _compiler_suffix=$(test $cc != gcc9 && echo $_cc) + echo >>$GITHUB_ENV _debug_suffix=$(test "$build_type" = dbg && echo -debug || true) + - name: Download artifact + uses: actions/download-artifact@v2 + with: + name: iroha-deb${{env.ARTIFACT_SUFFIX}} + - name: Rename artifact debs + run: | + mv *iroha_shepherd.deb docker/release/iroha_shepherd.deb + mv *irohad.deb docker/release/iroha.deb + - name: Determine dockertag + id: dockertag + run: | + echo "::set-output name=dockertag::$dockertag" + echo >>$GITHUB_ENV dockertag=$dockertag + test -n "$DOCKERHUB_ORG" || { + echo ::error::"DOCKERHUB_ORG must contain value" + false + } + env: + dockertag: ${{ hashFiles('docker/release/**') }} + - name: Docker meta + id: meta + uses: docker/metadata-action@v3 + with: + images: | + ${{ env.DOCKERHUB_ORG }}/${{ env.IMAGE_NAME }}${{ env._uses_suffix }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=ref,event=tag + type=schedule + flavor: | + suffix=${{env._compiler_suffix}}${{env._debug_suffix}},onlatest=true + #maybetodo flavor: prefix=${{ env.USES_PREFIX }} ## In case creating repository hyperledger/iroha-burrow denied, Use tag prefix hyperledger/iroha:burrow-xxxx + - uses: docker/metadata-action@v3 + name: Docker meta GHCR + id: meta_ghcr + with: + tags: | + type=ref,event=branch + type=ref,event=pr + type=ref,event=tag + type=schedule + flavor: | + suffix=${{env._compiler_suffix}}${{env._debug_suffix}},onlatest=true + #maybetodo flavor: prefix=${{ env.USES_PREFIX }} ## In case creating repository hyperledger/iroha-burrow denied, Use tag prefix hyperledger/iroha:burrow-xxxx + + images: ghcr.io/${{ github.repository }}${{ env._uses_suffix }} + - name: Login to DockerHub + #if: ${{ secrets.DOCKERHUB_TOKEN != '' && secrets.DOCKERHUB_USERNAME != '' }} + id: docker_login + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Log in to the Container registry GHCR + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Possible WARNING + if: ${{ steps.docker_login.outcome == 'skipped' }} + run: echo "::warning::DOCKERHUB_TOKEN and DOCKERHUB_USERNAME are empty. Will build but NOT push." + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-release-${{env.dockertag}} + restore-keys: ${{ runner.os }}-buildx-release + - id: build_and_push + name: Build and push + uses: docker/build-push-action@v2 + with: + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + # env: + # DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + # DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + + context: docker/release/ + push: ${{ steps.docker_login.outcome == 'success' }} + - uses: docker/build-push-action@v2 + id: build_and_push_ghcr + name: Build and push to GHCR + with: + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new + push: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo == github.event.pull_request.base.repo }} + tags: ${{ steps.meta_ghcr.outputs.tags }} + labels: ${{ steps.meta_ghcr.outputs.labels }} + # env: + # DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + # DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + + context: docker/release/ + - # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache + needs: + - build-UD + - generate_matrixes + # strategy: *strategy_ubuntu_debug + # if: *if_ubuntu_debug + strategy: + fail-fast: false + matrix: ${{ fromJSON( needs.generate_matrixes.outputs.matrix_dockerimage_debug ) }} + if: ${{ fromJSON( needs.generate_matrixes.outputs.matrix_dockerimage_debug ).include[0] }} From a4e5fd26b4961bb94316a0894911ed5b2f71369a Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 30 Mar 2022 09:35:56 +0300 Subject: [PATCH 005/130] Build all Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 4 ++-- .github/workflows/build-iroha1-fork.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index f370a7a80a4..7bf1c036592 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -98,8 +98,8 @@ jobs: true else #echo >/tmp/comment_body "/build debug; /build ubuntu release debug normal" - #echo >/tmp/comment_body "/build all" - echo >/tmp/comment_body "/build ubuntu debug clang-10 normal" + echo >/tmp/comment_body "/build all" + #echo >/tmp/comment_body "/build ubuntu debug clang-10 normal" fi ;; esac - diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index c8e17006f02..1fbaf60897d 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -120,8 +120,8 @@ jobs: true else #echo >/tmp/comment_body "/build debug; /build ubuntu release debug normal" - #echo >/tmp/comment_body "/build all" - echo >/tmp/comment_body "/build ubuntu debug clang-10 normal" + echo >/tmp/comment_body "/build all" + #echo >/tmp/comment_body "/build ubuntu debug clang-10 normal" fi ;; esac - name: Generate matrixes From 428d54f573cfe80242c72e646178008808b14288 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Thu, 31 Mar 2022 08:08:01 +0300 Subject: [PATCH 006/130] Run only one workflow Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 14 ++++++++++++++ .github/build-iroha1.src.yml | 16 +++++++++++++++- .github/workflows/build-iroha1-fork.yml | 11 +++++++++++ .github/workflows/build-iroha1.yml | 13 ++++++++++++- 4 files changed, 52 insertions(+), 2 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 7bf1c036592..3c4fc9edd8c 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -12,6 +12,20 @@ jobs: ## and that is why there is a workaround with make-workflows.sh ## You should `pre-commit install` or use `pre-commit-hook.sh`, ## anyway please read .github/README.md + + check_if_pull_request_comes_from_the_same_repo: + runs-on: ubuntu-20.04 #ubuntu-latest + name: Pull requests from forks should use other workflow + if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo == github.event.pull_request.base.repo }} + steps: + - + run: | + cat < Date: Thu, 31 Mar 2022 08:24:00 +0300 Subject: [PATCH 007/130] Run only one workflow Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 1 + .github/build-iroha1.src.yml | 1 + .github/workflows/build-iroha1-fork.yml | 1 + .github/workflows/build-iroha1.yml | 1 + 4 files changed, 4 insertions(+) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 3c4fc9edd8c..70cdb692734 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -29,6 +29,7 @@ jobs: check_workflow_yaml_coressponds_to_src_yaml: runs-on: ubuntu-20.04 #ubuntu-latest name: Check if github workflows were properly made from sources + needs: check_if_pull_request_comes_from_the_same_repo steps: - &step_show_context name: Show context diff --git a/.github/build-iroha1.src.yml b/.github/build-iroha1.src.yml index 34ffc74057f..8b4f37976b5 100644 --- a/.github/build-iroha1.src.yml +++ b/.github/build-iroha1.src.yml @@ -106,6 +106,7 @@ jobs: ## You should `pre-commit install` or use `pre-commit-hook.sh`, ## anyway please read .github/README.md check_workflow_yaml_coressponds_to_src_yaml: + needs: check_if_pull_request_comes_from_fork runs-on: ubuntu-20.04 #ubuntu-latest name: Check if github workflows were properly made from sources steps: diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index e9b64a5f2c1..32150b0e758 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -26,6 +26,7 @@ jobs: check_workflow_yaml_coressponds_to_src_yaml: runs-on: ubuntu-20.04 #ubuntu-latest name: Check if github workflows were properly made from sources + needs: check_if_pull_request_comes_from_the_same_repo steps: - name: Show context run: | diff --git a/.github/workflows/build-iroha1.yml b/.github/workflows/build-iroha1.yml index 722ac34cadb..987dc5b408c 100644 --- a/.github/workflows/build-iroha1.yml +++ b/.github/workflows/build-iroha1.yml @@ -104,6 +104,7 @@ jobs: ## You should `pre-commit install` or use `pre-commit-hook.sh`, ## anyway please read .github/README.md check_workflow_yaml_coressponds_to_src_yaml: + needs: check_if_pull_request_comes_from_fork runs-on: ubuntu-20.04 #ubuntu-latest name: Check if github workflows were properly made from sources steps: From 2ada7e50413cd828db8124809203e2ba09442af3 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Thu, 31 Mar 2022 08:34:10 +0300 Subject: [PATCH 008/130] Skip not-needed jobs Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 10 +++++----- .github/build-iroha1.src.yml | 8 ++++---- .github/workflows/build-iroha1-fork.yml | 13 ++++--------- .github/workflows/build-iroha1.yml | 8 ++++---- 4 files changed, 17 insertions(+), 22 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 70cdb692734..454fd5a5b23 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -13,23 +13,23 @@ jobs: ## You should `pre-commit install` or use `pre-commit-hook.sh`, ## anyway please read .github/README.md - check_if_pull_request_comes_from_the_same_repo: + check_if_pull_request_comes_from_fork: runs-on: ubuntu-20.04 #ubuntu-latest name: Pull requests from forks should use other workflow - if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo == github.event.pull_request.base.repo }} + if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo != github.event.pull_request.base.repo }} steps: - run: | cat < Date: Thu, 31 Mar 2022 08:55:07 +0300 Subject: [PATCH 009/130] Add comments to new checks Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 15 +++++++-------- .github/build-iroha1.src.yml | 6 ++---- .github/workflows/build-iroha1-fork.yml | 13 ++++++++----- .github/workflows/build-iroha1.yml | 6 ++---- 4 files changed, 19 insertions(+), 21 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 454fd5a5b23..c3baee6a27a 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -8,11 +8,9 @@ env: DOCKERHUB_ORG: hyperledger jobs: - ## GitHub Actions Workflow does not support yaml anchors - ## and that is why there is a workaround with make-workflows.sh - ## You should `pre-commit install` or use `pre-commit-hook.sh`, - ## anyway please read .github/README.md + ## This workflow is created for pull requests from forks only and has less permissions + ## This step allows to skip the workflow completely for pull_requests from th same repo check_if_pull_request_comes_from_fork: runs-on: ubuntu-20.04 #ubuntu-latest name: Pull requests from forks should use other workflow @@ -20,12 +18,13 @@ jobs: steps: - run: | - cat < Date: Thu, 31 Mar 2022 09:01:32 +0300 Subject: [PATCH 010/130] Make the new step first Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 1 + .github/build-iroha1.src.yml | 1 + .github/workflows/build-iroha1-fork.yml | 1 + .github/workflows/build-iroha1.yml | 1 + 4 files changed, 4 insertions(+) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index c3baee6a27a..aaa3f971529 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -72,6 +72,7 @@ jobs: generate_matrixes: runs-on: ubuntu-20.04 #ubuntu-latest + needs: check_if_pull_request_comes_from_fork #container: ubuntu:latest if: ${{ (github.event_name != 'comment') || ( github.event.comment && github.event.issue.pull_request && diff --git a/.github/build-iroha1.src.yml b/.github/build-iroha1.src.yml index 39903cd1907..be3e613dddc 100644 --- a/.github/build-iroha1.src.yml +++ b/.github/build-iroha1.src.yml @@ -172,6 +172,7 @@ jobs: ## - on workflow_dispatch according to its build_spec ## - on schedule '/build all' generate_matrixes: + needs: check_if_pull_request_comes_from_the_same_repo runs-on: ubuntu-20.04 #ubuntu-latest #container: ubuntu:latest if: ${{ (github.event_name != 'comment') || ( github.event.comment && diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 72854a55ca5..73af10c6312 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -71,6 +71,7 @@ jobs: [[ $(./.github/make-workflows.sh -x --worktree) = *"everything is up to date" ]] generate_matrixes: runs-on: ubuntu-20.04 #ubuntu-latest + needs: check_if_pull_request_comes_from_fork #container: ubuntu:latest if: ${{ (github.event_name != 'comment') || ( github.event.comment && github.event.issue.pull_request && startsWith(github.event.comment.body, '/build') ) }} steps: diff --git a/.github/workflows/build-iroha1.yml b/.github/workflows/build-iroha1.yml index 5a9aeba7c5e..14d210b025d 100644 --- a/.github/workflows/build-iroha1.yml +++ b/.github/workflows/build-iroha1.yml @@ -159,6 +159,7 @@ jobs: ## - on workflow_dispatch according to its build_spec ## - on schedule '/build all' generate_matrixes: + needs: check_if_pull_request_comes_from_the_same_repo runs-on: ubuntu-20.04 #ubuntu-latest #container: ubuntu:latest if: ${{ (github.event_name != 'comment') || ( github.event.comment && github.event.issue.pull_request && startsWith(github.event.comment.body, '/build') ) }} From 47bec5d9b00e10ac246f4a6e294b8d22d82baa82 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Thu, 31 Mar 2022 10:05:53 +0300 Subject: [PATCH 011/130] Do not allow to change iroha-builder Dockerfile Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 56 ++++++------------------- .github/workflows/build-iroha1-fork.yml | 51 +++++----------------- 2 files changed, 22 insertions(+), 85 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index aaa3f971529..6213b304302 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -55,12 +55,12 @@ jobs: "PR_NUM="+(.number|tostring), "PR_REPO="+.head.repo.full_name' >>$GITHUB_ENV - *step_show_context - - &step_checkout_base - name: Checkout base + - &step_checkout_head + name: Checkout head uses: actions/checkout@v2 - with: &step_checkout_with_base - ref: ${{env.PR_REF}} ## not empty on issue_comment, else default value GITHUB_REF - repository: ${{env.PR_REPO}} ## not empty on issue_comment, else default value github.repository, required by forks + with: &step_checkout_with_head + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} - run: sudo snap install yq - @@ -80,7 +80,7 @@ jobs: steps: - *step_show_context - *step_detect_commented_pr - - *step_checkout_base + - *step_checkout_head - name: Generate matrix for build triggered by chat-ops - comment to PR if: github.event.issue.pull_request && github.event.comment @@ -113,7 +113,7 @@ jobs: true else #echo >/tmp/comment_body "/build debug; /build ubuntu release debug normal" - echo >/tmp/comment_body "/build all" + echo >/tmp/comment_body "/build all skip_testing" #echo >/tmp/comment_body "/build ubuntu debug clang-10 normal" fi ;; esac @@ -163,10 +163,6 @@ jobs: Docker-iroha-builder: needs: check_workflow_yaml_coressponds_to_src_yaml runs-on: ubuntu-20.04 #ubuntu-latest #[ self-hosted, Linux ] - # env: &env_dockerhub - # DOCKERHUB_ORG: DOCKERHUB_ORG ## Must be hyperledger, also can use iroha1, cannot use ${{ secrets.DOCKERHUB_ORG }} - # DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - # DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} steps: - *step_show_context - &step_system_info @@ -190,12 +186,12 @@ jobs: event.issue.number:${{ github.event.issue.number }} END - *step_detect_commented_pr - - &step_checkout_head - name: Checkout head + - &step_checkout_base + name: Checkout base uses: actions/checkout@v2 - with: &step_checkout_with_head - ref: ${{github.event.pull_request.head.ref}} - repository: ${{github.event.pull_request.head.repo.full_name}} + with: &step_checkout_with_base + ref: ${{env.PR_REF}} ## not empty on issue_comment, else default value GITHUB_REF + repository: ${{env.PR_REPO}} ## not empty on issue_comment, else default value github.repository, required by forks - &step_docker_tag name: Determine dockertag id: dockertag @@ -302,34 +298,6 @@ jobs: run: | echo "::set-output name=container::$DOCKERHUB_ORG/iroha-builder:$dockertag" docker pull "$DOCKERHUB_ORG/iroha-builder:$dockertag" - - - name: Possible ERROR, Dockerfile edited, image was build, but seems not pushed, CANNOT PULL. - if: failure() - #if: ${{ steps.docker_login.outcome != 'success' || steps.build_and_push.outcome != 'success' }} - env: - container: ${{steps.dockertag_already.outputs.container}} - dockertag: ${{env.dockertag}} - run: | - cat </tmp/comment_body "/build all" + echo >/tmp/comment_body "/build all skip_testing" #echo >/tmp/comment_body "/build ubuntu debug clang-10 normal" fi ;; esac @@ -177,10 +177,6 @@ jobs: Docker-iroha-builder: needs: check_workflow_yaml_coressponds_to_src_yaml runs-on: ubuntu-20.04 #ubuntu-latest #[ self-hosted, Linux ] - # env: &env_dockerhub - # DOCKERHUB_ORG: DOCKERHUB_ORG ## Must be hyperledger, also can use iroha1, cannot use ${{ secrets.DOCKERHUB_ORG }} - # DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - # DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} steps: - name: Show context run: | @@ -221,11 +217,11 @@ jobs: "PR_SHA="+.head.sha, "PR_NUM="+(.number|tostring), "PR_REPO="+.head.repo.full_name' >>$GITHUB_ENV - - name: Checkout head + - name: Checkout base uses: actions/checkout@v2 with: - ref: ${{github.event.pull_request.head.ref}} - repository: ${{github.event.pull_request.head.repo.full_name}} + ref: ${{env.PR_REF}} ## not empty on issue_comment, else default value GITHUB_REF + repository: ${{env.PR_REPO}} ## not empty on issue_comment, else default value github.repository, required by forks - name: Determine dockertag id: dockertag env: @@ -334,33 +330,6 @@ jobs: run: | echo "::set-output name=container::$DOCKERHUB_ORG/iroha-builder:$dockertag" docker pull "$DOCKERHUB_ORG/iroha-builder:$dockertag" - - name: Possible ERROR, Dockerfile edited, image was build, but seems not pushed, CANNOT PULL. - if: failure() - #if: ${{ steps.docker_login.outcome != 'success' || steps.build_and_push.outcome != 'success' }} - env: - container: ${{steps.dockertag_already.outputs.container}} - dockertag: ${{env.dockertag}} - run: | - cat < Date: Thu, 31 Mar 2022 10:17:20 +0300 Subject: [PATCH 012/130] Do not allow to change iroha Dockerfile Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 2 +- .github/workflows/build-iroha1-fork.yml | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 6213b304302..3eb6d9c1c5d 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -750,7 +750,7 @@ jobs: - *step_build_info - *step_env_from_buildspec - *step_detect_commented_pr - - *step_checkout_head + - *step_checkout_base - *step_artifact_suffix - name: Download artifact uses: actions/download-artifact@v2 diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 520a3657fca..4d3aea08acc 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -1389,11 +1389,11 @@ jobs: "PR_SHA="+.head.sha, "PR_NUM="+(.number|tostring), "PR_REPO="+.head.repo.full_name' >>$GITHUB_ENV - - name: Checkout head + - name: Checkout base uses: actions/checkout@v2 with: - ref: ${{github.event.pull_request.head.ref}} - repository: ${{github.event.pull_request.head.repo.full_name}} + ref: ${{env.PR_REF}} ## not empty on issue_comment, else default value GITHUB_REF + repository: ${{env.PR_REPO}} ## not empty on issue_comment, else default value github.repository, required by forks - name: Generate artifact suffix depending on matrix to env.ARTIFACT_SUFFIX run: | set -x @@ -1573,11 +1573,11 @@ jobs: "PR_SHA="+.head.sha, "PR_NUM="+(.number|tostring), "PR_REPO="+.head.repo.full_name' >>$GITHUB_ENV - - name: Checkout head + - name: Checkout base uses: actions/checkout@v2 with: - ref: ${{github.event.pull_request.head.ref}} - repository: ${{github.event.pull_request.head.repo.full_name}} + ref: ${{env.PR_REF}} ## not empty on issue_comment, else default value GITHUB_REF + repository: ${{env.PR_REPO}} ## not empty on issue_comment, else default value github.repository, required by forks - name: Generate artifact suffix depending on matrix to env.ARTIFACT_SUFFIX run: | set -x From 9cc0702872076b1c23cffd02367ddc239a86749a Mon Sep 17 00:00:00 2001 From: safinsaf Date: Thu, 31 Mar 2022 11:10:17 +0300 Subject: [PATCH 013/130] Debug iroha workflow not running Signed-off-by: safinsaf --- .github/build-iroha1.src.yml | 15 ++++++++++++++- .github/workflows/build-iroha1.yml | 14 +++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/.github/build-iroha1.src.yml b/.github/build-iroha1.src.yml index be3e613dddc..90c73deaff5 100644 --- a/.github/build-iroha1.src.yml +++ b/.github/build-iroha1.src.yml @@ -93,8 +93,21 @@ jobs: check_if_pull_request_comes_from_the_same_repo: runs-on: ubuntu-20.04 #ubuntu-latest name: Pull requests from forks should use other workflow - if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo == github.event.pull_request.base.repo }} + #if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo == github.event.pull_request.base.repo }} steps: + - + name: Show context + run: | + echo "::group::GitHub context" + cat <<'END' + ${{ toJson(github) }} + END + echo "::endgroup::" + echo "::group::GitHub needs" + cat <<'END' + ${{ toJson(needs) }} + END + echo "::endgroup::" - run: | true diff --git a/.github/workflows/build-iroha1.yml b/.github/workflows/build-iroha1.yml index 14d210b025d..d300963d70e 100644 --- a/.github/workflows/build-iroha1.yml +++ b/.github/workflows/build-iroha1.yml @@ -93,8 +93,20 @@ jobs: check_if_pull_request_comes_from_the_same_repo: runs-on: ubuntu-20.04 #ubuntu-latest name: Pull requests from forks should use other workflow - if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo == github.event.pull_request.base.repo }} + #if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo == github.event.pull_request.base.repo }} steps: + - name: Show context + run: | + echo "::group::GitHub context" + cat <<'END' + ${{ toJson(github) }} + END + echo "::endgroup::" + echo "::group::GitHub needs" + cat <<'END' + ${{ toJson(needs) }} + END + echo "::endgroup::" - run: | true ## GitHub Actions Workflow does not support yaml anchors From e6dc321bec1a03b4a13ed79a726abfe6a5eab7a3 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Thu, 31 Mar 2022 11:15:19 +0300 Subject: [PATCH 014/130] Debug iroha workflow not running Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 2 +- .github/build-iroha1.src.yml | 2 +- .github/workflows/build-iroha1-fork.yml | 2 +- .github/workflows/build-iroha1.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 3eb6d9c1c5d..1e752c7b740 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -14,7 +14,7 @@ jobs: check_if_pull_request_comes_from_fork: runs-on: ubuntu-20.04 #ubuntu-latest name: Pull requests from forks should use other workflow - if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo != github.event.pull_request.base.repo }} + if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name }} steps: - run: | diff --git a/.github/build-iroha1.src.yml b/.github/build-iroha1.src.yml index 90c73deaff5..ffe021c8d15 100644 --- a/.github/build-iroha1.src.yml +++ b/.github/build-iroha1.src.yml @@ -93,7 +93,7 @@ jobs: check_if_pull_request_comes_from_the_same_repo: runs-on: ubuntu-20.04 #ubuntu-latest name: Pull requests from forks should use other workflow - #if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo == github.event.pull_request.base.repo }} + if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name }} steps: - name: Show context diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 4d3aea08acc..035fd35f506 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -13,7 +13,7 @@ jobs: check_if_pull_request_comes_from_fork: runs-on: ubuntu-20.04 #ubuntu-latest name: Pull requests from forks should use other workflow - if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo != github.event.pull_request.base.repo }} + if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name }} steps: - run: | true diff --git a/.github/workflows/build-iroha1.yml b/.github/workflows/build-iroha1.yml index d300963d70e..b5c29e7a56a 100644 --- a/.github/workflows/build-iroha1.yml +++ b/.github/workflows/build-iroha1.yml @@ -93,7 +93,7 @@ jobs: check_if_pull_request_comes_from_the_same_repo: runs-on: ubuntu-20.04 #ubuntu-latest name: Pull requests from forks should use other workflow - #if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo == github.event.pull_request.base.repo }} + if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name }} steps: - name: Show context run: | From 52a7f787fffa09c940e07cff1dcb2e04fc4dd87d Mon Sep 17 00:00:00 2001 From: safinsaf Date: Fri, 1 Apr 2022 09:26:51 +0300 Subject: [PATCH 015/130] Show all changed files Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 25 ++++++++++++++++++++++--- .github/workflows/build-iroha1-fork.yml | 18 ++++++++++++++++-- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 1e752c7b740..8da60a29552 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -2,7 +2,7 @@ name: Iroha1-fork on: pull_request_target: - branches: [ feature/DOPS-1651/enable-fork-build ] ## target branches + branches: [ main, support/1.*, edge, develop, feature/DOPS-1651/enable-fork-build ] ## target branches env: DOCKERHUB_ORG: hyperledger @@ -10,7 +10,7 @@ env: jobs: ## This workflow is created for pull requests from forks only and has less permissions - ## This step allows to skip the workflow completely for pull_requests from th same repo + ## This step allows to skip the workflow completely for pull_requests from the same repo check_if_pull_request_comes_from_fork: runs-on: ubuntu-20.04 #ubuntu-latest name: Pull requests from forks should use other workflow @@ -19,7 +19,25 @@ jobs: - run: | true + + - &step_checkout_head + name: Checkout head + uses: actions/checkout@v2 + with: &step_checkout_with_head + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} + + - + name: Get changed files + id: changed-files + uses: tj-actions/changed-files@v18.6 + - + name: List all changed files + run: | + for file in ${{ steps.changed-files.outputs.all_changed_files }}; do + echo "$file was changed" + done ## GitHub Actions Workflow does not support yaml anchors ## and that is why there is a workaround with make-workflows.sh @@ -55,7 +73,8 @@ jobs: "PR_NUM="+(.number|tostring), "PR_REPO="+.head.repo.full_name' >>$GITHUB_ENV - *step_show_context - - &step_checkout_head + #- &step_checkout_head + - name: Checkout head uses: actions/checkout@v2 with: &step_checkout_with_head diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 035fd35f506..12210c9ede5 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -4,12 +4,12 @@ name: Iroha1-fork on: pull_request_target: - branches: [feature/DOPS-1651/enable-fork-build] ## target branches + branches: [main, support/1.*, edge, develop, feature/DOPS-1651/enable-fork-build] ## target branches env: DOCKERHUB_ORG: hyperledger jobs: ## This workflow is created for pull requests from forks only and has less permissions - ## This step allows to skip the workflow completely for pull_requests from th same repo + ## This step allows to skip the workflow completely for pull_requests from the same repo check_if_pull_request_comes_from_fork: runs-on: ubuntu-20.04 #ubuntu-latest name: Pull requests from forks should use other workflow @@ -17,6 +17,19 @@ jobs: steps: - run: | true + - name: Checkout head + uses: actions/checkout@v2 + with: + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} + - name: Get changed files + id: changed-files + uses: tj-actions/changed-files@v18.6 + - name: List all changed files + run: | + for file in ${{ steps.changed-files.outputs.all_changed_files }}; do + echo "$file was changed" + done ## GitHub Actions Workflow does not support yaml anchors ## and that is why there is a workaround with make-workflows.sh ## You should `pre-commit install` or use `pre-commit-hook.sh`, @@ -59,6 +72,7 @@ jobs: ${{ toJson(needs) }} END echo "::endgroup::" + #- &step_checkout_head - name: Checkout head uses: actions/checkout@v2 with: From 192d68850ff3dd914d2d66b4169598759a8bf6c7 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Fri, 1 Apr 2022 09:32:59 +0300 Subject: [PATCH 016/130] Fetch history of commits for diff Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 7 +++---- .github/workflows/build-iroha1-fork.yml | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 8da60a29552..c92054d5419 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -20,13 +20,13 @@ jobs: run: | true - - &step_checkout_head + - name: Checkout head uses: actions/checkout@v2 with: &step_checkout_with_head ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} - + fetch-depth: 0 - name: Get changed files id: changed-files @@ -73,8 +73,7 @@ jobs: "PR_NUM="+(.number|tostring), "PR_REPO="+.head.repo.full_name' >>$GITHUB_ENV - *step_show_context - #- &step_checkout_head - - + - &step_checkout_head name: Checkout head uses: actions/checkout@v2 with: &step_checkout_with_head diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 12210c9ede5..352142bc1f3 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -22,6 +22,7 @@ jobs: with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} + fetch-depth: 0 - name: Get changed files id: changed-files uses: tj-actions/changed-files@v18.6 @@ -72,7 +73,6 @@ jobs: ${{ toJson(needs) }} END echo "::endgroup::" - #- &step_checkout_head - name: Checkout head uses: actions/checkout@v2 with: From 6d3a12942a3321b7636485d6b5c38fb1643a9bbf Mon Sep 17 00:00:00 2001 From: safinsaf Date: Fri, 1 Apr 2022 09:43:17 +0300 Subject: [PATCH 017/130] Try checkout base for mode Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 9 ++++----- .github/workflows/build-iroha1-fork.yml | 7 +++---- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index c92054d5419..11fe7dde264 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -21,12 +21,11 @@ jobs: true - - name: Checkout head + name: Checkout base uses: actions/checkout@v2 - with: &step_checkout_with_head - ref: ${{github.event.pull_request.head.ref}} - repository: ${{github.event.pull_request.head.repo.full_name}} - fetch-depth: 0 + with: &step_checkout_with_base + ref: ${{env.PR_REF}} ## not empty on issue_comment, else default value GITHUB_REF + repository: ${{env.PR_REPO}} ## not empty on issue_comment, else default value github.repository, required by forks - name: Get changed files id: changed-files diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 352142bc1f3..7e4e1c2c570 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -17,12 +17,11 @@ jobs: steps: - run: | true - - name: Checkout head + - name: Checkout base uses: actions/checkout@v2 with: - ref: ${{github.event.pull_request.head.ref}} - repository: ${{github.event.pull_request.head.repo.full_name}} - fetch-depth: 0 + ref: ${{env.PR_REF}} ## not empty on issue_comment, else default value GITHUB_REF + repository: ${{env.PR_REPO}} ## not empty on issue_comment, else default value github.repository, required by forks - name: Get changed files id: changed-files uses: tj-actions/changed-files@v18.6 From fbb6f1378cefaaccfe2c799fad79f5fdd78dc154 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Fri, 1 Apr 2022 09:49:42 +0300 Subject: [PATCH 018/130] Try checkout v3 on head for diff Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 10 +++++----- .github/workflows/build-iroha1-fork.yml | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 11fe7dde264..e0721f78fb9 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -21,11 +21,11 @@ jobs: true - - name: Checkout base - uses: actions/checkout@v2 - with: &step_checkout_with_base - ref: ${{env.PR_REF}} ## not empty on issue_comment, else default value GITHUB_REF - repository: ${{env.PR_REPO}} ## not empty on issue_comment, else default value github.repository, required by forks + name: Checkout head + uses: actions/checkout@v3 + with: + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} - name: Get changed files id: changed-files diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 7e4e1c2c570..a143fc978cd 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -17,11 +17,11 @@ jobs: steps: - run: | true - - name: Checkout base - uses: actions/checkout@v2 + - name: Checkout head + uses: actions/checkout@v3 with: - ref: ${{env.PR_REF}} ## not empty on issue_comment, else default value GITHUB_REF - repository: ${{env.PR_REPO}} ## not empty on issue_comment, else default value github.repository, required by forks + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} - name: Get changed files id: changed-files uses: tj-actions/changed-files@v18.6 From d082ccb0f90a7097bb29946f64d5a52e989208b2 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Fri, 1 Apr 2022 09:54:22 +0300 Subject: [PATCH 019/130] Allow use fork point Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 2 ++ .github/workflows/build-iroha1-fork.yml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index e0721f78fb9..2f8df051257 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -30,6 +30,8 @@ jobs: name: Get changed files id: changed-files uses: tj-actions/changed-files@v18.6 + with: + use_fork_point: True - name: List all changed files diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index a143fc978cd..27c0ec10354 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -25,6 +25,8 @@ jobs: - name: Get changed files id: changed-files uses: tj-actions/changed-files@v18.6 + with: + use_fork_point: True - name: List all changed files run: | for file in ${{ steps.changed-files.outputs.all_changed_files }}; do From b999162625feb8ffab19580b769139c1bedc23db Mon Sep 17 00:00:00 2001 From: safinsaf Date: Fri, 1 Apr 2022 10:08:33 +0300 Subject: [PATCH 020/130] Find fork point Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 6 ++++++ .github/workflows/build-iroha1-fork.yml | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 2f8df051257..511162f8b1e 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -26,6 +26,12 @@ jobs: with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} + + - name: Find common ancestor + env: + FORK_BASE_BRANCH: ${{ github.base_ref }} + run: git merge-base --fork-point origin/$BASE_BRANCH + - name: Get changed files id: changed-files diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 27c0ec10354..91a72c1e535 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -22,6 +22,10 @@ jobs: with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} + - name: Find common ancestor + env: + FORK_BASE_BRANCH: ${{ github.base_ref }} + run: git merge-base --fork-point origin/$BASE_BRANCH - name: Get changed files id: changed-files uses: tj-actions/changed-files@v18.6 From 0c942c0d2b7965bc4ac1db1ccac1e07602bfffdb Mon Sep 17 00:00:00 2001 From: safinsaf Date: Fri, 1 Apr 2022 10:11:23 +0300 Subject: [PATCH 021/130] Find fork point Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 2 +- .github/workflows/build-iroha1-fork.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 511162f8b1e..a2b1d8703c1 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -30,7 +30,7 @@ jobs: - name: Find common ancestor env: FORK_BASE_BRANCH: ${{ github.base_ref }} - run: git merge-base --fork-point origin/$BASE_BRANCH + run: git merge-base --fork-point origin/$FORK_BASE_BRANCH - name: Get changed files diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 91a72c1e535..83a376ecbfe 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -25,7 +25,7 @@ jobs: - name: Find common ancestor env: FORK_BASE_BRANCH: ${{ github.base_ref }} - run: git merge-base --fork-point origin/$BASE_BRANCH + run: git merge-base --fork-point origin/$FORK_BASE_BRANCH - name: Get changed files id: changed-files uses: tj-actions/changed-files@v18.6 From 2b5ec58d0f88c82301b708e62da322e268ac4d04 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Mon, 4 Apr 2022 10:24:26 +0300 Subject: [PATCH 022/130] Fix finding ancestor Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 10 +++++++++- .github/workflows/build-iroha1-fork.yml | 7 ++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index a2b1d8703c1..7180e4a1fad 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -27,10 +27,18 @@ jobs: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} + - + name: Set second remote + with: + url: ${{github.event.pull_request.base.repo.ssh_url}} + run: | + git remote add base {{url}} + + - name: Find common ancestor env: FORK_BASE_BRANCH: ${{ github.base_ref }} - run: git merge-base --fork-point origin/$FORK_BASE_BRANCH + run: git merge-base --fork-point base/$FORK_BASE_BRANCH - name: Get changed files diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 83a376ecbfe..fb850bb2de8 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -22,10 +22,15 @@ jobs: with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} + - name: Set second remote + with: + url: ${{github.event.pull_request.base.repo.ssh_url}} + run: | + git remote add base {{url}} - name: Find common ancestor env: FORK_BASE_BRANCH: ${{ github.base_ref }} - run: git merge-base --fork-point origin/$FORK_BASE_BRANCH + run: git merge-base --fork-point base/$FORK_BASE_BRANCH - name: Get changed files id: changed-files uses: tj-actions/changed-files@v18.6 From 27284611522be67cdcefe66aa3182ca6511dafe1 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Tue, 5 Apr 2022 08:19:39 +0300 Subject: [PATCH 023/130] Try to remove variable in setting new origin Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 4 +--- .github/workflows/build-iroha1-fork.yml | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 7180e4a1fad..1bec722a564 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -29,10 +29,8 @@ jobs: - name: Set second remote - with: - url: ${{github.event.pull_request.base.repo.ssh_url}} run: | - git remote add base {{url}} + git remote add base {{github.event.pull_request.base.repo.ssh_url}} - name: Find common ancestor diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index fb850bb2de8..c0033fc8b46 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -23,10 +23,8 @@ jobs: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} - name: Set second remote - with: - url: ${{github.event.pull_request.base.repo.ssh_url}} run: | - git remote add base {{url}} + git remote add base {{github.event.pull_request.base.repo.ssh_url}} - name: Find common ancestor env: FORK_BASE_BRANCH: ${{ github.base_ref }} From 6901d3749438bd07afd10d47378ae3d9ae0f1b5f Mon Sep 17 00:00:00 2001 From: safinsaf Date: Tue, 5 Apr 2022 08:50:11 +0300 Subject: [PATCH 024/130] Fix finding ancestor Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 17 ++++++++++------- .github/workflows/build-iroha1-fork.yml | 12 ++++++++---- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 1bec722a564..0d25867f86b 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -28,22 +28,25 @@ jobs: repository: ${{github.event.pull_request.head.repo.full_name}} - - name: Set second remote + name: Find common ancestor + id: ancestor run: | git remote add base {{github.event.pull_request.base.repo.ssh_url}} - - - - name: Find common ancestor + git fetch base + echo "::set-output ancestor_sha=ancestor_sha::$(git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH)" env: FORK_BASE_BRANCH: ${{ github.base_ref }} - run: git merge-base --fork-point base/$FORK_BASE_BRANCH - + FORK_HEAD_BRANCH: ${{ github.head_ref }} + outputs: + ancestor_sha: ${{steps.ancestor.outputs.ancestor_sha}} + + - name: Get changed files id: changed-files uses: tj-actions/changed-files@v18.6 with: - use_fork_point: True + base_sha: ${{ needs.ancestor.outputs.ancestor_sha }} - name: List all changed files diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index c0033fc8b46..3a0038af3d0 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -22,18 +22,22 @@ jobs: with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} - - name: Set second remote + - name: Find common ancestor + id: ancestor run: | git remote add base {{github.event.pull_request.base.repo.ssh_url}} - - name: Find common ancestor + git fetch base + echo "::set-output ancestor_sha=ancestor_sha::$(git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH)" env: FORK_BASE_BRANCH: ${{ github.base_ref }} - run: git merge-base --fork-point base/$FORK_BASE_BRANCH + FORK_HEAD_BRANCH: ${{ github.head_ref }} + outputs: + ancestor_sha: ${{steps.ancestor.outputs.ancestor_sha}} - name: Get changed files id: changed-files uses: tj-actions/changed-files@v18.6 with: - use_fork_point: True + base_sha: ${{ needs.ancestor.outputs.ancestor_sha }} - name: List all changed files run: | for file in ${{ steps.changed-files.outputs.all_changed_files }}; do From df873452a1fcc74faf5ef8bc98c2135b217f764b Mon Sep 17 00:00:00 2001 From: safinsaf Date: Tue, 5 Apr 2022 10:00:29 +0300 Subject: [PATCH 025/130] Fix output Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 7 +++---- .github/workflows/build-iroha1-fork.yml | 6 +++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 0d25867f86b..c3d4354321c 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -33,13 +33,12 @@ jobs: run: | git remote add base {{github.event.pull_request.base.repo.ssh_url}} git fetch base - echo "::set-output ancestor_sha=ancestor_sha::$(git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH)" + echo "::set-output name=ancestor_sha::$(git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH)" env: FORK_BASE_BRANCH: ${{ github.base_ref }} FORK_HEAD_BRANCH: ${{ github.head_ref }} - outputs: - ancestor_sha: ${{steps.ancestor.outputs.ancestor_sha}} - + # outputs: + # ancestor_sha: ${{steps.ancestor.outputs.ancestor_sha}} - name: Get changed files diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 3a0038af3d0..cd84d2a3409 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -27,12 +27,12 @@ jobs: run: | git remote add base {{github.event.pull_request.base.repo.ssh_url}} git fetch base - echo "::set-output ancestor_sha=ancestor_sha::$(git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH)" + echo "::set-output name=ancestor_sha::$(git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH)" env: FORK_BASE_BRANCH: ${{ github.base_ref }} FORK_HEAD_BRANCH: ${{ github.head_ref }} - outputs: - ancestor_sha: ${{steps.ancestor.outputs.ancestor_sha}} + # outputs: + # ancestor_sha: ${{steps.ancestor.outputs.ancestor_sha}} - name: Get changed files id: changed-files uses: tj-actions/changed-files@v18.6 From 081348ee2d3c353feb6aab0a4af581ae8c866009 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Tue, 5 Apr 2022 10:10:25 +0300 Subject: [PATCH 026/130] Try fix base origin Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 2 +- .github/workflows/build-iroha1-fork.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index c3d4354321c..23f627a6cb0 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -31,7 +31,7 @@ jobs: name: Find common ancestor id: ancestor run: | - git remote add base {{github.event.pull_request.base.repo.ssh_url}} + git remote add base {{github.event.pull_request.base.repo.svn_url}} git fetch base echo "::set-output name=ancestor_sha::$(git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH)" env: diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index cd84d2a3409..9cd37d4ae4d 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -25,7 +25,7 @@ jobs: - name: Find common ancestor id: ancestor run: | - git remote add base {{github.event.pull_request.base.repo.ssh_url}} + git remote add base {{github.event.pull_request.base.repo.svn_url}} git fetch base echo "::set-output name=ancestor_sha::$(git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH)" env: From 0ea5bafd26684d80e55c6f01b6a38fbb867ed4f6 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Tue, 5 Apr 2022 10:14:00 +0300 Subject: [PATCH 027/130] Try fix base origin Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 2 +- .github/workflows/build-iroha1-fork.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 23f627a6cb0..674a17f2fea 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -31,7 +31,7 @@ jobs: name: Find common ancestor id: ancestor run: | - git remote add base {{github.event.pull_request.base.repo.svn_url}} + git remote add base ${{github.event.pull_request.base.repo.ssh_url}} git fetch base echo "::set-output name=ancestor_sha::$(git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH)" env: diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 9cd37d4ae4d..aea5bc9c3df 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -25,7 +25,7 @@ jobs: - name: Find common ancestor id: ancestor run: | - git remote add base {{github.event.pull_request.base.repo.svn_url}} + git remote add base ${{github.event.pull_request.base.repo.ssh_url}} git fetch base echo "::set-output name=ancestor_sha::$(git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH)" env: From 534c28de8b59a51158550b77e9f58a8f133ae324 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Tue, 5 Apr 2022 10:17:22 +0300 Subject: [PATCH 028/130] Try fix base origin Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 2 +- .github/workflows/build-iroha1-fork.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 674a17f2fea..23f627a6cb0 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -31,7 +31,7 @@ jobs: name: Find common ancestor id: ancestor run: | - git remote add base ${{github.event.pull_request.base.repo.ssh_url}} + git remote add base {{github.event.pull_request.base.repo.svn_url}} git fetch base echo "::set-output name=ancestor_sha::$(git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH)" env: diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index aea5bc9c3df..9cd37d4ae4d 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -25,7 +25,7 @@ jobs: - name: Find common ancestor id: ancestor run: | - git remote add base ${{github.event.pull_request.base.repo.ssh_url}} + git remote add base {{github.event.pull_request.base.repo.svn_url}} git fetch base echo "::set-output name=ancestor_sha::$(git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH)" env: From 752306c4d129ab862dcbc23a611ef12a20c26076 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Tue, 5 Apr 2022 10:19:22 +0300 Subject: [PATCH 029/130] Try fix base origin Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 2 +- .github/workflows/build-iroha1-fork.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 23f627a6cb0..6f504bd5dbf 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -31,7 +31,7 @@ jobs: name: Find common ancestor id: ancestor run: | - git remote add base {{github.event.pull_request.base.repo.svn_url}} + git remote add base ${{github.event.pull_request.base.repo.svn_url}} git fetch base echo "::set-output name=ancestor_sha::$(git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH)" env: diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 9cd37d4ae4d..bc3efbfc060 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -25,7 +25,7 @@ jobs: - name: Find common ancestor id: ancestor run: | - git remote add base {{github.event.pull_request.base.repo.svn_url}} + git remote add base ${{github.event.pull_request.base.repo.svn_url}} git fetch base echo "::set-output name=ancestor_sha::$(git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH)" env: From 38636e3063b51bd5fa430445a02d4acd5ff9b34c Mon Sep 17 00:00:00 2001 From: safinsaf Date: Tue, 5 Apr 2022 10:31:34 +0300 Subject: [PATCH 030/130] Try fix base origin Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 3 ++- .github/workflows/build-iroha1-fork.yml | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 6f504bd5dbf..8fea9420634 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -33,7 +33,8 @@ jobs: run: | git remote add base ${{github.event.pull_request.base.repo.svn_url}} git fetch base - echo "::set-output name=ancestor_sha::$(git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH)" + git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH + echo "::set-output name=ancestor_sha::$(!!)" env: FORK_BASE_BRANCH: ${{ github.base_ref }} FORK_HEAD_BRANCH: ${{ github.head_ref }} diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index bc3efbfc060..6560c900fc4 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -27,7 +27,8 @@ jobs: run: | git remote add base ${{github.event.pull_request.base.repo.svn_url}} git fetch base - echo "::set-output name=ancestor_sha::$(git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH)" + git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH + echo "::set-output name=ancestor_sha::$(!!)" env: FORK_BASE_BRANCH: ${{ github.base_ref }} FORK_HEAD_BRANCH: ${{ github.head_ref }} From 0c318a029993f573435f4bc90cb697bf4e351c27 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Tue, 5 Apr 2022 11:07:30 +0300 Subject: [PATCH 031/130] Try fix base origin Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 8fea9420634..f54e2e93b8d 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -33,8 +33,9 @@ jobs: run: | git remote add base ${{github.event.pull_request.base.repo.svn_url}} git fetch base - git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH - echo "::set-output name=ancestor_sha::$(!!)" + export COMMAND="git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH" + #echo "git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH" | sh + echo "::set-output name=ancestor_sha::$(echo $COMMAND | sh)" env: FORK_BASE_BRANCH: ${{ github.base_ref }} FORK_HEAD_BRANCH: ${{ github.head_ref }} From 6a9001e7a61a13ad34b3fd63a5a1d69f132e0c82 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 08:40:32 +0300 Subject: [PATCH 032/130] Use export for setting output Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 1 - .github/workflows/build-iroha1-fork.yml | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index f54e2e93b8d..a341f5f9200 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -34,7 +34,6 @@ jobs: git remote add base ${{github.event.pull_request.base.repo.svn_url}} git fetch base export COMMAND="git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH" - #echo "git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH" | sh echo "::set-output name=ancestor_sha::$(echo $COMMAND | sh)" env: FORK_BASE_BRANCH: ${{ github.base_ref }} diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 6560c900fc4..ccbf836ae6a 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -27,8 +27,8 @@ jobs: run: | git remote add base ${{github.event.pull_request.base.repo.svn_url}} git fetch base - git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH - echo "::set-output name=ancestor_sha::$(!!)" + export COMMAND="git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH" + echo "::set-output name=ancestor_sha::$(echo $COMMAND | sh)" env: FORK_BASE_BRANCH: ${{ github.base_ref }} FORK_HEAD_BRANCH: ${{ github.head_ref }} From 2b3a8fe15a6f1eec0b9c0341fc6e579845483175 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 08:48:58 +0300 Subject: [PATCH 033/130] Try saving to file Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 4 ++-- .github/workflows/build-iroha1-fork.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index a341f5f9200..21aedd79f47 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -33,8 +33,8 @@ jobs: run: | git remote add base ${{github.event.pull_request.base.repo.svn_url}} git fetch base - export COMMAND="git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH" - echo "::set-output name=ancestor_sha::$(echo $COMMAND | sh)" + echo "git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH" > command.sh + echo "::set-output name=ancestor_sha::$(sh command.sh)" env: FORK_BASE_BRANCH: ${{ github.base_ref }} FORK_HEAD_BRANCH: ${{ github.head_ref }} diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index ccbf836ae6a..4b3ddf29b7d 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -27,8 +27,8 @@ jobs: run: | git remote add base ${{github.event.pull_request.base.repo.svn_url}} git fetch base - export COMMAND="git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH" - echo "::set-output name=ancestor_sha::$(echo $COMMAND | sh)" + echo "git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH" > command.sh + echo "::set-output name=ancestor_sha::$(sh command.sh)" env: FORK_BASE_BRANCH: ${{ github.base_ref }} FORK_HEAD_BRANCH: ${{ github.head_ref }} From a4200548ed6e2ef93db7b1380e9e7e43dea8a1b3 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 08:53:04 +0300 Subject: [PATCH 034/130] Try saving to file Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 3 ++- .github/workflows/build-iroha1-fork.yml | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 21aedd79f47..54d5edb161e 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -34,7 +34,8 @@ jobs: git remote add base ${{github.event.pull_request.base.repo.svn_url}} git fetch base echo "git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH" > command.sh - echo "::set-output name=ancestor_sha::$(sh command.sh)" + cat command.sh + echo "::set-output name=ancestor_sha::$(cat command.sh | sh)" env: FORK_BASE_BRANCH: ${{ github.base_ref }} FORK_HEAD_BRANCH: ${{ github.head_ref }} diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 4b3ddf29b7d..f8b8516efba 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -28,7 +28,8 @@ jobs: git remote add base ${{github.event.pull_request.base.repo.svn_url}} git fetch base echo "git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH" > command.sh - echo "::set-output name=ancestor_sha::$(sh command.sh)" + cat command.sh + echo "::set-output name=ancestor_sha::$(cat command.sh | sh)" env: FORK_BASE_BRANCH: ${{ github.base_ref }} FORK_HEAD_BRANCH: ${{ github.head_ref }} From 1fcbe981a30a38d4ece60d3ab60bd0837470cf1d Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 08:55:26 +0300 Subject: [PATCH 035/130] Try saving to file Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 2 +- .github/workflows/build-iroha1-fork.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 54d5edb161e..773d57deede 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -35,7 +35,7 @@ jobs: git fetch base echo "git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH" > command.sh cat command.sh - echo "::set-output name=ancestor_sha::$(cat command.sh | sh)" + echo "::set-output name=ancestor_sha::$(cat command.sh)" env: FORK_BASE_BRANCH: ${{ github.base_ref }} FORK_HEAD_BRANCH: ${{ github.head_ref }} diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index f8b8516efba..27ba6fd3879 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -29,7 +29,7 @@ jobs: git fetch base echo "git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH" > command.sh cat command.sh - echo "::set-output name=ancestor_sha::$(cat command.sh | sh)" + echo "::set-output name=ancestor_sha::$(cat command.sh)" env: FORK_BASE_BRANCH: ${{ github.base_ref }} FORK_HEAD_BRANCH: ${{ github.head_ref }} From 8576887f86089eccfc8afeda669921798dda7c25 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 09:00:31 +0300 Subject: [PATCH 036/130] Try saving to file Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 2 +- .github/workflows/build-iroha1-fork.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 773d57deede..d8801f474ac 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -33,7 +33,7 @@ jobs: run: | git remote add base ${{github.event.pull_request.base.repo.svn_url}} git fetch base - echo "git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH" > command.sh + git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH > command.sh cat command.sh echo "::set-output name=ancestor_sha::$(cat command.sh)" env: diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 27ba6fd3879..d99a38659ef 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -27,7 +27,7 @@ jobs: run: | git remote add base ${{github.event.pull_request.base.repo.svn_url}} git fetch base - echo "git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH" > command.sh + git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH > command.sh cat command.sh echo "::set-output name=ancestor_sha::$(cat command.sh)" env: From d2aff0d8e3ae30eaaa16904dec3ce35a28d4743b Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 09:02:42 +0300 Subject: [PATCH 037/130] Try saving to file Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 2 +- .github/workflows/build-iroha1-fork.yml | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index d8801f474ac..0627c0a7ae2 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -35,7 +35,7 @@ jobs: git fetch base git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH > command.sh cat command.sh - echo "::set-output name=ancestor_sha::$(cat command.sh)" + env: FORK_BASE_BRANCH: ${{ github.base_ref }} FORK_HEAD_BRANCH: ${{ github.head_ref }} diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index d99a38659ef..9efbcfcd8f0 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -29,7 +29,6 @@ jobs: git fetch base git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH > command.sh cat command.sh - echo "::set-output name=ancestor_sha::$(cat command.sh)" env: FORK_BASE_BRANCH: ${{ github.base_ref }} FORK_HEAD_BRANCH: ${{ github.head_ref }} From 160a675f096fff7671994e733d02cd70f48d9a83 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 09:06:06 +0300 Subject: [PATCH 038/130] Try saving to file Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 3 +-- .github/workflows/build-iroha1-fork.yml | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 0627c0a7ae2..980cc266e2f 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -34,8 +34,7 @@ jobs: git remote add base ${{github.event.pull_request.base.repo.svn_url}} git fetch base git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH > command.sh - cat command.sh - + env: FORK_BASE_BRANCH: ${{ github.base_ref }} FORK_HEAD_BRANCH: ${{ github.head_ref }} diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 9efbcfcd8f0..68f6a7fb275 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -28,7 +28,6 @@ jobs: git remote add base ${{github.event.pull_request.base.repo.svn_url}} git fetch base git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH > command.sh - cat command.sh env: FORK_BASE_BRANCH: ${{ github.base_ref }} FORK_HEAD_BRANCH: ${{ github.head_ref }} From fbec820879b79b6376c935b911d028b6a94e418d Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 09:24:00 +0300 Subject: [PATCH 039/130] Debug using hardcoded values Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 2 +- .github/workflows/build-iroha1-fork.yml | 2 +- command.sh | 0 3 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 command.sh diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 980cc266e2f..7daa36bff10 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -33,7 +33,7 @@ jobs: run: | git remote add base ${{github.event.pull_request.base.repo.svn_url}} git fetch base - git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH > command.sh + git merge-base base/feature/DOPS-1651/enable-fork-build origin/main env: FORK_BASE_BRANCH: ${{ github.base_ref }} diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 68f6a7fb275..9c3468a0bd1 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -27,7 +27,7 @@ jobs: run: | git remote add base ${{github.event.pull_request.base.repo.svn_url}} git fetch base - git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH > command.sh + git merge-base base/feature/DOPS-1651/enable-fork-build origin/main env: FORK_BASE_BRANCH: ${{ github.base_ref }} FORK_HEAD_BRANCH: ${{ github.head_ref }} diff --git a/command.sh b/command.sh new file mode 100644 index 00000000000..e69de29bb2d From 21dca1303a8ff91c46e501517812ff52385fef1a Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 09:27:05 +0300 Subject: [PATCH 040/130] Debug using hardcoded values Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 1 + .github/workflows/build-iroha1-fork.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 7daa36bff10..400352797a0 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -32,6 +32,7 @@ jobs: id: ancestor run: | git remote add base ${{github.event.pull_request.base.repo.svn_url}} + git remote add origin ${{github.event.pull_request.head.repo.svn_url}} git fetch base git merge-base base/feature/DOPS-1651/enable-fork-build origin/main diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 9c3468a0bd1..107ca28373d 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -26,6 +26,7 @@ jobs: id: ancestor run: | git remote add base ${{github.event.pull_request.base.repo.svn_url}} + git remote add origin ${{github.event.pull_request.head.repo.svn_url}} git fetch base git merge-base base/feature/DOPS-1651/enable-fork-build origin/main env: From 3461e24d9169a33bccc0c71df939efb4750e370d Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 09:28:31 +0300 Subject: [PATCH 041/130] Debug using hardcoded values Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 12 ++++++------ .github/workflows/build-iroha1-fork.yml | 11 ++++++----- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 400352797a0..10ecefc142a 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -20,12 +20,12 @@ jobs: run: | true - - - name: Checkout head - uses: actions/checkout@v3 - with: - ref: ${{github.event.pull_request.head.ref}} - repository: ${{github.event.pull_request.head.repo.full_name}} + # - + # name: Checkout head + # uses: actions/checkout@v3 + # with: + # ref: ${{github.event.pull_request.head.ref}} + # repository: ${{github.event.pull_request.head.repo.full_name}} - name: Find common ancestor diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 107ca28373d..1453eee77a0 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -17,11 +17,12 @@ jobs: steps: - run: | true - - name: Checkout head - uses: actions/checkout@v3 - with: - ref: ${{github.event.pull_request.head.ref}} - repository: ${{github.event.pull_request.head.repo.full_name}} + # - + # name: Checkout head + # uses: actions/checkout@v3 + # with: + # ref: ${{github.event.pull_request.head.ref}} + # repository: ${{github.event.pull_request.head.repo.full_name}} - name: Find common ancestor id: ancestor run: | From 190ae0a23bc009c11cb5ef0bc031700544826e98 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 09:30:50 +0300 Subject: [PATCH 042/130] Debug using hardcoded values Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 16 ++++++++-------- .github/workflows/build-iroha1-fork.yml | 15 +++++++-------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 10ecefc142a..f3b712da954 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -20,21 +20,21 @@ jobs: run: | true - # - - # name: Checkout head - # uses: actions/checkout@v3 - # with: - # ref: ${{github.event.pull_request.head.ref}} - # repository: ${{github.event.pull_request.head.repo.full_name}} + - + name: Checkout head + uses: actions/checkout@v3 + with: + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} - name: Find common ancestor id: ancestor run: | git remote add base ${{github.event.pull_request.base.repo.svn_url}} - git remote add origin ${{github.event.pull_request.head.repo.svn_url}} + git remote add head ${{github.event.pull_request.head.repo.svn_url}} git fetch base - git merge-base base/feature/DOPS-1651/enable-fork-build origin/main + git merge-base base/feature/DOPS-1651/enable-fork-build head/main env: FORK_BASE_BRANCH: ${{ github.base_ref }} diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 1453eee77a0..cf1038d97fa 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -17,19 +17,18 @@ jobs: steps: - run: | true - # - - # name: Checkout head - # uses: actions/checkout@v3 - # with: - # ref: ${{github.event.pull_request.head.ref}} - # repository: ${{github.event.pull_request.head.repo.full_name}} + - name: Checkout head + uses: actions/checkout@v3 + with: + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} - name: Find common ancestor id: ancestor run: | git remote add base ${{github.event.pull_request.base.repo.svn_url}} - git remote add origin ${{github.event.pull_request.head.repo.svn_url}} + git remote add head ${{github.event.pull_request.head.repo.svn_url}} git fetch base - git merge-base base/feature/DOPS-1651/enable-fork-build origin/main + git merge-base base/feature/DOPS-1651/enable-fork-build head/main env: FORK_BASE_BRANCH: ${{ github.base_ref }} FORK_HEAD_BRANCH: ${{ github.head_ref }} From 541f0a5ac36d835a3ded1f93d0772f820f952eb7 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 09:35:25 +0300 Subject: [PATCH 043/130] Debug using hardcoded values Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 1 + .github/workflows/build-iroha1-fork.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index f3b712da954..2825a07e6f3 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -34,6 +34,7 @@ jobs: git remote add base ${{github.event.pull_request.base.repo.svn_url}} git remote add head ${{github.event.pull_request.head.repo.svn_url}} git fetch base + git fetch head git merge-base base/feature/DOPS-1651/enable-fork-build head/main env: diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index cf1038d97fa..899624a3ea5 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -28,6 +28,7 @@ jobs: git remote add base ${{github.event.pull_request.base.repo.svn_url}} git remote add head ${{github.event.pull_request.head.repo.svn_url}} git fetch base + git fetch head git merge-base base/feature/DOPS-1651/enable-fork-build head/main env: FORK_BASE_BRANCH: ${{ github.base_ref }} From 332afdb2859ea39f3b7d3b515867ff990c90c84c Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 09:41:24 +0300 Subject: [PATCH 044/130] Try other action Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 55 ++++++++++++++----------- .github/workflows/build-iroha1-fork.yml | 51 ++++++++++++++--------- 2 files changed, 62 insertions(+), 44 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 2825a07e6f3..ec18188f276 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -27,36 +27,43 @@ jobs: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} - - - name: Find common ancestor - id: ancestor - run: | - git remote add base ${{github.event.pull_request.base.repo.svn_url}} - git remote add head ${{github.event.pull_request.head.repo.svn_url}} - git fetch base - git fetch head - git merge-base base/feature/DOPS-1651/enable-fork-build head/main + # - + # name: Find common ancestor + # id: ancestor + # run: | + # git remote add base ${{github.event.pull_request.base.repo.svn_url}} + # git remote add head ${{github.event.pull_request.head.repo.svn_url}} + # git fetch base + # git fetch head + # git merge-base base/feature/DOPS-1651/enable-fork-build head/main - env: - FORK_BASE_BRANCH: ${{ github.base_ref }} - FORK_HEAD_BRANCH: ${{ github.head_ref }} + # env: + # FORK_BASE_BRANCH: ${{ github.base_ref }} + # FORK_HEAD_BRANCH: ${{ github.head_ref }} # outputs: # ancestor_sha: ${{steps.ancestor.outputs.ancestor_sha}} - - - name: Get changed files - id: changed-files - uses: tj-actions/changed-files@v18.6 - with: - base_sha: ${{ needs.ancestor.outputs.ancestor_sha }} - - - - name: List all changed files - run: | - for file in ${{ steps.changed-files.outputs.all_changed_files }}; do - echo "$file was changed" + - id: files + uses: jitterbit/get-changed-files@v1 + - run: | + for changed_file in ${{ steps.files.outputs.all }}; do + echo "Do something with this ${changed_file}." done + # - + # name: Get changed files + # id: changed-files + # uses: tj-actions/changed-files@v18.6 + # with: + # base_sha: ${{ needs.ancestor.outputs.ancestor_sha }} + + # - + # name: List all changed files + # run: | + # for file in ${{ steps.changed-files.outputs.all_changed_files }}; do + # echo "$file was changed" + # done + ## GitHub Actions Workflow does not support yaml anchors ## and that is why there is a workaround with make-workflows.sh ## You should `pre-commit install` or use `pre-commit-hook.sh`, diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 899624a3ea5..2e36de757ac 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -22,29 +22,40 @@ jobs: with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} - - name: Find common ancestor - id: ancestor - run: | - git remote add base ${{github.event.pull_request.base.repo.svn_url}} - git remote add head ${{github.event.pull_request.head.repo.svn_url}} - git fetch base - git fetch head - git merge-base base/feature/DOPS-1651/enable-fork-build head/main - env: - FORK_BASE_BRANCH: ${{ github.base_ref }} - FORK_HEAD_BRANCH: ${{ github.head_ref }} + # - + # name: Find common ancestor + # id: ancestor + # run: | + # git remote add base ${{github.event.pull_request.base.repo.svn_url}} + # git remote add head ${{github.event.pull_request.head.repo.svn_url}} + # git fetch base + # git fetch head + # git merge-base base/feature/DOPS-1651/enable-fork-build head/main + + # env: + # FORK_BASE_BRANCH: ${{ github.base_ref }} + # FORK_HEAD_BRANCH: ${{ github.head_ref }} # outputs: # ancestor_sha: ${{steps.ancestor.outputs.ancestor_sha}} - - name: Get changed files - id: changed-files - uses: tj-actions/changed-files@v18.6 - with: - base_sha: ${{ needs.ancestor.outputs.ancestor_sha }} - - name: List all changed files - run: | - for file in ${{ steps.changed-files.outputs.all_changed_files }}; do - echo "$file was changed" + - id: files + uses: jitterbit/get-changed-files@v1 + - run: | + for changed_file in ${{ steps.files.outputs.all }}; do + echo "Do something with this ${changed_file}." done + # - + # name: Get changed files + # id: changed-files + # uses: tj-actions/changed-files@v18.6 + # with: + # base_sha: ${{ needs.ancestor.outputs.ancestor_sha }} + + # - + # name: List all changed files + # run: | + # for file in ${{ steps.changed-files.outputs.all_changed_files }}; do + # echo "$file was changed" + # done ## GitHub Actions Workflow does not support yaml anchors ## and that is why there is a workaround with make-workflows.sh ## You should `pre-commit install` or use `pre-commit-hook.sh`, From 0d373c4333a56bd2af36bec718f03bccfb3943b8 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 09:49:27 +0300 Subject: [PATCH 045/130] Try other action Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 17 ++++++++---- .github/workflows/build-iroha1-fork.yml | 37 +++++++++++++------------ 2 files changed, 30 insertions(+), 24 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index ec18188f276..5d4a9343f76 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -43,12 +43,17 @@ jobs: # outputs: # ancestor_sha: ${{steps.ancestor.outputs.ancestor_sha}} - - id: files - uses: jitterbit/get-changed-files@v1 - - run: | - for changed_file in ${{ steps.files.outputs.all }}; do - echo "Do something with this ${changed_file}." - done + - + name: Filter files + uses: dorny/paths-filter@v2 + id: filter + + - + name: backend tests + run: + echo "$files" + with: + files: ${{ steps.filter.outputs.changed_files }} # - # name: Get changed files diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 2e36de757ac..fe6116344d8 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -37,25 +37,26 @@ jobs: # FORK_HEAD_BRANCH: ${{ github.head_ref }} # outputs: # ancestor_sha: ${{steps.ancestor.outputs.ancestor_sha}} - - id: files - uses: jitterbit/get-changed-files@v1 - - run: | - for changed_file in ${{ steps.files.outputs.all }}; do - echo "Do something with this ${changed_file}." - done - # - - # name: Get changed files - # id: changed-files - # uses: tj-actions/changed-files@v18.6 - # with: - # base_sha: ${{ needs.ancestor.outputs.ancestor_sha }} + - name: Filter files + uses: dorny/paths-filter@v2 + id: filter + - name: backend tests + run: echo "$files" + with: + files: ${{ steps.filter.outputs.changed_files }} + # - + # name: Get changed files + # id: changed-files + # uses: tj-actions/changed-files@v18.6 + # with: + # base_sha: ${{ needs.ancestor.outputs.ancestor_sha }} - # - - # name: List all changed files - # run: | - # for file in ${{ steps.changed-files.outputs.all_changed_files }}; do - # echo "$file was changed" - # done + # - + # name: List all changed files + # run: | + # for file in ${{ steps.changed-files.outputs.all_changed_files }}; do + # echo "$file was changed" + # done ## GitHub Actions Workflow does not support yaml anchors ## and that is why there is a workaround with make-workflows.sh ## You should `pre-commit install` or use `pre-commit-hook.sh`, From 782f85383acfbf139972a432acdb7961612b0d6b Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 09:51:24 +0300 Subject: [PATCH 046/130] Try other action Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 6 +++--- .github/workflows/build-iroha1-fork.yml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 5d4a9343f76..57c2ce09c71 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -51,9 +51,9 @@ jobs: - name: backend tests run: - echo "$files" - with: - files: ${{ steps.filter.outputs.changed_files }} + echo "$changed_files" + env: + changed_files: ${{ steps.filter.outputs.changed_files }} # - # name: Get changed files diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index fe6116344d8..54715f9bdd6 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -41,9 +41,9 @@ jobs: uses: dorny/paths-filter@v2 id: filter - name: backend tests - run: echo "$files" - with: - files: ${{ steps.filter.outputs.changed_files }} + run: echo "$changed_files" + env: + changed_files: ${{ steps.filter.outputs.changed_files }} # - # name: Get changed files # id: changed-files From 6fa516e1439053c85c7e8f9af4a7a085edeac62f Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 09:53:27 +0300 Subject: [PATCH 047/130] Try other action Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 4 ++++ .github/workflows/build-iroha1-fork.yml | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 57c2ce09c71..e669f3313ee 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -47,6 +47,10 @@ jobs: name: Filter files uses: dorny/paths-filter@v2 id: filter + with: + filters: | + github: + - '.github/**' - name: backend tests diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 54715f9bdd6..c1febb4b592 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -40,6 +40,10 @@ jobs: - name: Filter files uses: dorny/paths-filter@v2 id: filter + with: + filters: | + github: + - '.github/**' - name: backend tests run: echo "$changed_files" env: From 2de5e2e9ff4da6554b1c12e1980fd528e5bd33a7 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 09:58:28 +0300 Subject: [PATCH 048/130] Try other action Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 45 +++---------------------- .github/workflows/build-iroha1-fork.yml | 36 ++------------------ 2 files changed, 6 insertions(+), 75 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index e669f3313ee..6c291b407da 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -16,10 +16,7 @@ jobs: name: Pull requests from forks should use other workflow if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name }} steps: - - - run: | - true - + - name: Checkout head uses: actions/checkout@v3 @@ -27,22 +24,6 @@ jobs: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} - # - - # name: Find common ancestor - # id: ancestor - # run: | - # git remote add base ${{github.event.pull_request.base.repo.svn_url}} - # git remote add head ${{github.event.pull_request.head.repo.svn_url}} - # git fetch base - # git fetch head - # git merge-base base/feature/DOPS-1651/enable-fork-build head/main - - # env: - # FORK_BASE_BRANCH: ${{ github.base_ref }} - # FORK_HEAD_BRANCH: ${{ github.head_ref }} - # outputs: - # ancestor_sha: ${{steps.ancestor.outputs.ancestor_sha}} - - name: Filter files uses: dorny/paths-filter@v2 @@ -51,27 +32,9 @@ jobs: filters: | github: - '.github/**' - - - - name: backend tests - run: - echo "$changed_files" - env: - changed_files: ${{ steps.filter.outputs.changed_files }} - - # - - # name: Get changed files - # id: changed-files - # uses: tj-actions/changed-files@v18.6 - # with: - # base_sha: ${{ needs.ancestor.outputs.ancestor_sha }} - - # - - # name: List all changed files - # run: | - # for file in ${{ steps.changed-files.outputs.all_changed_files }}; do - # echo "$file was changed" - # done + dockerfile: + - '**/Dockerfile' + ## GitHub Actions Workflow does not support yaml anchors ## and that is why there is a workaround with make-workflows.sh diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index c1febb4b592..85e62edf0b2 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -15,28 +15,11 @@ jobs: name: Pull requests from forks should use other workflow if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name }} steps: - - run: | - true - name: Checkout head uses: actions/checkout@v3 with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} - # - - # name: Find common ancestor - # id: ancestor - # run: | - # git remote add base ${{github.event.pull_request.base.repo.svn_url}} - # git remote add head ${{github.event.pull_request.head.repo.svn_url}} - # git fetch base - # git fetch head - # git merge-base base/feature/DOPS-1651/enable-fork-build head/main - - # env: - # FORK_BASE_BRANCH: ${{ github.base_ref }} - # FORK_HEAD_BRANCH: ${{ github.head_ref }} - # outputs: - # ancestor_sha: ${{steps.ancestor.outputs.ancestor_sha}} - name: Filter files uses: dorny/paths-filter@v2 id: filter @@ -44,23 +27,8 @@ jobs: filters: | github: - '.github/**' - - name: backend tests - run: echo "$changed_files" - env: - changed_files: ${{ steps.filter.outputs.changed_files }} - # - - # name: Get changed files - # id: changed-files - # uses: tj-actions/changed-files@v18.6 - # with: - # base_sha: ${{ needs.ancestor.outputs.ancestor_sha }} - - # - - # name: List all changed files - # run: | - # for file in ${{ steps.changed-files.outputs.all_changed_files }}; do - # echo "$file was changed" - # done + dockerfile: + - '**/Dockerfile' ## GitHub Actions Workflow does not support yaml anchors ## and that is why there is a workaround with make-workflows.sh ## You should `pre-commit install` or use `pre-commit-hook.sh`, From baaf74f886ec4be306e27b169c72152d126888b9 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 10:08:12 +0300 Subject: [PATCH 049/130] Try other action Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 12 ++++++++++++ .github/workflows/build-iroha1-fork.yml | 10 ++++++++++ 2 files changed, 22 insertions(+) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 6c291b407da..368184de373 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -35,6 +35,18 @@ jobs: dockerfile: - '**/Dockerfile' + - name: verify .github folder is not changed + if: steps.filter.outputs.github == 'true' + run: | + echo "Pull requests from forks are not allowed to change .github folder" + false + + - name: verify Dockerfiles are not changed + if: steps.filter.outputs.dockerfile == 'true' + run: | + echo "Pull requests from forks are not allowed to change Dockerfiles" + false + ## GitHub Actions Workflow does not support yaml anchors ## and that is why there is a workaround with make-workflows.sh diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 85e62edf0b2..a4d1f0ef6f3 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -29,6 +29,16 @@ jobs: - '.github/**' dockerfile: - '**/Dockerfile' + - name: verify .github folder is not changed + if: steps.filter.outputs.github == 'true' + run: | + echo "Pull requests from forks are not allowed to change .github folder" + false + - name: verify Dockerfiles are not changed + if: steps.filter.outputs.dockerfile == 'true' + run: | + echo "Pull requests from forks are not allowed to change Dockerfiles" + false ## GitHub Actions Workflow does not support yaml anchors ## and that is why there is a workaround with make-workflows.sh ## You should `pre-commit install` or use `pre-commit-hook.sh`, From be7dbe77f34a5191bb02a2a32b37fb1ad39acfc3 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 10:37:34 +0300 Subject: [PATCH 050/130] Add comments, replace some anchors Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 24 ++++++++++-------------- .github/build-iroha1.src.yml | 11 ++++------- .github/workflows/build-iroha1-fork.yml | 5 +++-- .github/workflows/build-iroha1.yml | 11 +++-------- 4 files changed, 20 insertions(+), 31 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 368184de373..ea0064ec356 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -1,5 +1,7 @@ name: Iroha1-fork +## This workflow is created for pull requests from forks only and has less permissions than build-iroha1 workflow + on: pull_request_target: branches: [ main, support/1.*, edge, develop, feature/DOPS-1651/enable-fork-build ] ## target branches @@ -9,21 +11,21 @@ env: jobs: - ## This workflow is created for pull requests from forks only and has less permissions + ## This step allows to skip the workflow completely for pull_requests from the same repo + ## Also it checks that that .github folder and Dockerfiles are not changed check_if_pull_request_comes_from_fork: runs-on: ubuntu-20.04 #ubuntu-latest name: Pull requests from forks should use other workflow if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name }} steps: - - - + + - &step_checkout_head name: Checkout head - uses: actions/checkout@v3 - with: + uses: actions/checkout@v2 + with: &step_checkout_with_head ref: ${{github.event.pull_request.head.ref}} - repository: ${{github.event.pull_request.head.repo.full_name}} - + repository: ${{github.event.pull_request.head.repo.full_name}} - name: Filter files uses: dorny/paths-filter@v2 @@ -47,7 +49,6 @@ jobs: echo "Pull requests from forks are not allowed to change Dockerfiles" false - ## GitHub Actions Workflow does not support yaml anchors ## and that is why there is a workaround with make-workflows.sh ## You should `pre-commit install` or use `pre-commit-hook.sh`, @@ -82,12 +83,7 @@ jobs: "PR_NUM="+(.number|tostring), "PR_REPO="+.head.repo.full_name' >>$GITHUB_ENV - *step_show_context - - &step_checkout_head - name: Checkout head - uses: actions/checkout@v2 - with: &step_checkout_with_head - ref: ${{github.event.pull_request.head.ref}} - repository: ${{github.event.pull_request.head.repo.full_name}} + - *step_checkout_head - run: sudo snap install yq - diff --git a/.github/build-iroha1.src.yml b/.github/build-iroha1.src.yml index ffe021c8d15..2d20a786e18 100644 --- a/.github/build-iroha1.src.yml +++ b/.github/build-iroha1.src.yml @@ -1,5 +1,9 @@ name: Iroha1 +## IMPORTANT +## This workflow is not run for forks, check build-iroha1-fork for pull_requests from forks + + ## TODO IMPORTANT DISALLOW deploying tags and main and develop builds where skip_testing was set. ## TODO 1. [vcpkg,optimization-space,optimization-speed] ## Build only Debug or only Release - reduce vcpkg build duration and output size 2times @@ -22,13 +26,7 @@ name: Iroha1 ## TODO [cmake,dockerimage,iroha-builder] To improve speed of vcpkg step install to iroha-builder ## docker image cmake 3.20.1 or later and ninja 1.10.1 or later. ## TODO actions/create-release for tags -## TODO use event pull_request_target to handle PRs from authorized forks, -## assert they do not change workflow.yml because it is not applied. -## CHEAT SHEET -## check if PR head repo is fork: ${{ github.event.pull_request.head.repo.fork }} -## check if PR is from other repo: ${{ github.event.pull_request.head.repo == github.event.pull_request.base.repo }} in this case secrets are empty -## ternary: ${{ fromJSON('["no", "yes"]')[github.ref != 'refs/heads/master'] }} ## PITFAILS ## * checkout issue on self-hosted runner with Docker, see https://github.com/actions/runner/issues/434 @@ -42,7 +40,6 @@ name: Iroha1 ## * AWS-hosted runners could respond slowly, it often takes about 1 minute or more to prepare runner, if it was not idling. ## * AWS-hosted runners has maximum active runners quote, ask @bulat5 or @Sofiane_bnh to increase if required. ## * Our AWS-hosted runners are shared with Iroha2 -## * Secrets are inaccessable for PRs from public forks. GH-token is read-only. No way to push dockerimages when PR is from fork. ## * Docker containers must run as root, see checkout issue https://github.com/actions/runner/issues/434 ## TODO make these different workflows - reduce number of conditionals inside jobs like 'step_detect_commented_pr' diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index a4d1f0ef6f3..5119b5f0a41 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -2,21 +2,22 @@ ## Generated from build-iroha1-fork.src.yml with make-workflows.sh name: Iroha1-fork +## This workflow is created for pull requests from forks only and has less permissions than build-iroha1 workflow on: pull_request_target: branches: [main, support/1.*, edge, develop, feature/DOPS-1651/enable-fork-build] ## target branches env: DOCKERHUB_ORG: hyperledger jobs: - ## This workflow is created for pull requests from forks only and has less permissions ## This step allows to skip the workflow completely for pull_requests from the same repo + ## Also it checks that that .github folder and Dockerfiles are not changed check_if_pull_request_comes_from_fork: runs-on: ubuntu-20.04 #ubuntu-latest name: Pull requests from forks should use other workflow if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name }} steps: - name: Checkout head - uses: actions/checkout@v3 + uses: actions/checkout@v2 with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} diff --git a/.github/workflows/build-iroha1.yml b/.github/workflows/build-iroha1.yml index b5c29e7a56a..b3d6aeea387 100644 --- a/.github/workflows/build-iroha1.yml +++ b/.github/workflows/build-iroha1.yml @@ -2,6 +2,9 @@ ## Generated from build-iroha1.src.yml with make-workflows.sh name: Iroha1 +## IMPORTANT +## This workflow is not run for forks, check build-iroha1-fork for pull_requests from forks + ## TODO IMPORTANT DISALLOW deploying tags and main and develop builds where skip_testing was set. ## TODO 1. [vcpkg,optimization-space,optimization-speed] ## Build only Debug or only Release - reduce vcpkg build duration and output size 2times @@ -24,13 +27,6 @@ name: Iroha1 ## TODO [cmake,dockerimage,iroha-builder] To improve speed of vcpkg step install to iroha-builder ## docker image cmake 3.20.1 or later and ninja 1.10.1 or later. ## TODO actions/create-release for tags -## TODO use event pull_request_target to handle PRs from authorized forks, -## assert they do not change workflow.yml because it is not applied. - -## CHEAT SHEET -## check if PR head repo is fork: ${{ github.event.pull_request.head.repo.fork }} -## check if PR is from other repo: ${{ github.event.pull_request.head.repo == github.event.pull_request.base.repo }} in this case secrets are empty -## ternary: ${{ fromJSON('["no", "yes"]')[github.ref != 'refs/heads/master'] }} ## PITFAILS ## * checkout issue on self-hosted runner with Docker, see https://github.com/actions/runner/issues/434 @@ -44,7 +40,6 @@ name: Iroha1 ## * AWS-hosted runners could respond slowly, it often takes about 1 minute or more to prepare runner, if it was not idling. ## * AWS-hosted runners has maximum active runners quote, ask @bulat5 or @Sofiane_bnh to increase if required. ## * Our AWS-hosted runners are shared with Iroha2 -## * Secrets are inaccessable for PRs from public forks. GH-token is read-only. No way to push dockerimages when PR is from fork. ## * Docker containers must run as root, see checkout issue https://github.com/actions/runner/issues/434 ## TODO make these different workflows - reduce number of conditionals inside jobs like 'step_detect_commented_pr' From 35975bdcd188ddf88c3c06baabdc80f8cbb4e626 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 10:52:15 +0300 Subject: [PATCH 051/130] Remove non-needed job Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 49 +++----------- .github/workflows/build-iroha1-fork.yml | 88 +------------------------ 2 files changed, 12 insertions(+), 125 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index ea0064ec356..2337acecdba 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -49,14 +49,14 @@ jobs: echo "Pull requests from forks are not allowed to change Dockerfiles" false - ## GitHub Actions Workflow does not support yaml anchors - ## and that is why there is a workaround with make-workflows.sh - ## You should `pre-commit install` or use `pre-commit-hook.sh`, - ## anyway please read .github/README.md - check_workflow_yaml_coressponds_to_src_yaml: + + generate_matrixes: runs-on: ubuntu-20.04 #ubuntu-latest - name: Check if github workflows were properly made from sources needs: check_if_pull_request_comes_from_fork + #container: ubuntu:latest + if: ${{ (github.event_name != 'comment') || ( github.event.comment && + github.event.issue.pull_request && + startsWith(github.event.comment.body, '/build') ) }} steps: - &step_show_context name: Show context @@ -82,27 +82,6 @@ jobs: "PR_SHA="+.head.sha, "PR_NUM="+(.number|tostring), "PR_REPO="+.head.repo.full_name' >>$GITHUB_ENV - - *step_show_context - - *step_checkout_head - - - run: sudo snap install yq - - - name: Check if .github/workflows/*.yml correspond to *.src.yml - run: | - set -x - [[ $(./.github/make-workflows.sh -x --worktree) = *"everything is up to date" ]] - - - generate_matrixes: - runs-on: ubuntu-20.04 #ubuntu-latest - needs: check_if_pull_request_comes_from_fork - #container: ubuntu:latest - if: ${{ (github.event_name != 'comment') || ( github.event.comment && - github.event.issue.pull_request && - startsWith(github.event.comment.body, '/build') ) }} - steps: - - *step_show_context - - *step_detect_commented_pr - *step_checkout_head - name: Generate matrix for build triggered by chat-ops - comment to PR @@ -184,7 +163,7 @@ jobs: matrix_dockerimage_debug: ${{steps.matrixes.outputs.matrix_dockerimage_debug}} Docker-iroha-builder: - needs: check_workflow_yaml_coressponds_to_src_yaml + needs: check_if_pull_request_comes_from_fork runs-on: ubuntu-20.04 #ubuntu-latest #[ self-hosted, Linux ] steps: - *step_show_context @@ -292,9 +271,6 @@ jobs: push: ${{ steps.docker_login.outcome == 'success' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - # env: - # DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - # DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} - &step_docker_build_and_push_ghcr <<: *step_docker_build_and_push id: build_and_push_ghcr @@ -304,9 +280,6 @@ jobs: push: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo == github.event.pull_request.base.repo }} tags: ${{ steps.meta_ghcr.outputs.tags }} labels: ${{ steps.meta_ghcr.outputs.labels }} - # env: - # DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - # DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} - &step_docker_move_cache # Temp fix # https://github.com/docker/build-push-action/issues/252 @@ -339,7 +312,6 @@ jobs: - Docker-iroha-builder - generate_matrixes runs-on: [ self-hosted, Linux ] - #runs-on: ubuntu-20.04 container: ## Container is taken from previous job image: &container_image ${{needs.Docker-iroha-builder.outputs.container}} options: --user root @@ -619,7 +591,7 @@ jobs: ## Just to align picture prepare-macos-env: - needs: check_workflow_yaml_coressponds_to_src_yaml + needs: check_if_pull_request_comes_from_fork runs-on: macos-latest steps: - *step_show_context @@ -687,7 +659,7 @@ jobs: ## Just to align picture prepare-windows-env: - needs: check_workflow_yaml_coressponds_to_src_yaml + needs: check_if_pull_request_comes_from_fork runs-on: windows-latest steps: - *step_show_context @@ -762,9 +734,6 @@ jobs: fail-fast: false matrix: ${{ fromJSON( needs.generate_matrixes.outputs.matrix_dockerimage_release ) }} if: ${{ fromJSON( needs.generate_matrixes.outputs.matrix_dockerimage_release ).include[0] }} - #env: &env_dockerhub_release - # <<: *env_dockerhub - # IMAGE_NAME: iroha env: IMAGE_NAME: iroha steps: diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 5119b5f0a41..47cbd332d18 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -40,58 +40,6 @@ jobs: run: | echo "Pull requests from forks are not allowed to change Dockerfiles" false - ## GitHub Actions Workflow does not support yaml anchors - ## and that is why there is a workaround with make-workflows.sh - ## You should `pre-commit install` or use `pre-commit-hook.sh`, - ## anyway please read .github/README.md - check_workflow_yaml_coressponds_to_src_yaml: - runs-on: ubuntu-20.04 #ubuntu-latest - name: Check if github workflows were properly made from sources - needs: check_if_pull_request_comes_from_fork - steps: - - name: Show context - run: | - echo "::group::GitHub context" - cat <<'END' - ${{ toJson(github) }} - END - echo "::endgroup::" - echo "::group::GitHub needs" - cat <<'END' - ${{ toJson(needs) }} - END - echo "::endgroup::" - - name: REF and SHA of commented PR to ENV - if: github.event.comment - run: > - curl -fsSL ${{github.event.issue.pull_request.url}} -H "Authorization: token ${{github.token}}" | jq -r ' - - "PR_REF="+.head.ref, - "PR_SHA="+.head.sha, - "PR_NUM="+(.number|tostring), - "PR_REPO="+.head.repo.full_name' >>$GITHUB_ENV - - name: Show context - run: | - echo "::group::GitHub context" - cat <<'END' - ${{ toJson(github) }} - END - echo "::endgroup::" - echo "::group::GitHub needs" - cat <<'END' - ${{ toJson(needs) }} - END - echo "::endgroup::" - - name: Checkout head - uses: actions/checkout@v2 - with: - ref: ${{github.event.pull_request.head.ref}} - repository: ${{github.event.pull_request.head.repo.full_name}} - - run: sudo snap install yq - - name: Check if .github/workflows/*.yml correspond to *.src.yml - run: | - set -x - [[ $(./.github/make-workflows.sh -x --worktree) = *"everything is up to date" ]] generate_matrixes: runs-on: ubuntu-20.04 #ubuntu-latest needs: check_if_pull_request_comes_from_fork @@ -198,7 +146,7 @@ jobs: matrix_dockerimage_release: ${{steps.matrixes.outputs.matrix_dockerimage_release}} matrix_dockerimage_debug: ${{steps.matrixes.outputs.matrix_dockerimage_debug}} Docker-iroha-builder: - needs: check_workflow_yaml_coressponds_to_src_yaml + needs: check_if_pull_request_comes_from_fork runs-on: ubuntu-20.04 #ubuntu-latest #[ self-hosted, Linux ] steps: - name: Show context @@ -325,9 +273,6 @@ jobs: push: ${{ steps.docker_login.outcome == 'success' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - # env: - # DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - # DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} - uses: docker/build-push-action@v2 id: build_and_push_ghcr name: Build and push to GHCR @@ -338,9 +283,6 @@ jobs: push: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo == github.event.pull_request.base.repo }} tags: ${{ steps.meta_ghcr.outputs.tags }} labels: ${{ steps.meta_ghcr.outputs.labels }} - # env: - # DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - # DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} - # Temp fix # https://github.com/docker/build-push-action/issues/252 # https://github.com/moby/buildkit/issues/1896 @@ -369,7 +311,6 @@ jobs: - Docker-iroha-builder - generate_matrixes runs-on: [self-hosted, Linux] - #runs-on: ubuntu-20.04 container: ## Container is taken from previous job image: ${{needs.Docker-iroha-builder.outputs.container}} options: --user root @@ -656,7 +597,6 @@ jobs: - Docker-iroha-builder - generate_matrixes runs-on: [self-hosted, Linux] - #runs-on: ubuntu-20.04 container: ## Container is taken from previous job image: ${{needs.Docker-iroha-builder.outputs.container}} options: --user root @@ -939,7 +879,7 @@ jobs: if: ${{ fromJSON( needs.generate_matrixes.outputs.matrix_ubuntu_release ).include[0] }} ## Just to align picture prepare-macos-env: - needs: check_workflow_yaml_coressponds_to_src_yaml + needs: check_if_pull_request_comes_from_fork runs-on: macos-latest steps: - name: Show context @@ -1238,7 +1178,7 @@ jobs: timeout-minutes: 70 ## Just to align picture prepare-windows-env: - needs: check_workflow_yaml_coressponds_to_src_yaml + needs: check_if_pull_request_comes_from_fork runs-on: windows-latest steps: - name: Show context @@ -1353,9 +1293,6 @@ jobs: fail-fast: false matrix: ${{ fromJSON( needs.generate_matrixes.outputs.matrix_dockerimage_release ) }} if: ${{ fromJSON( needs.generate_matrixes.outputs.matrix_dockerimage_release ).include[0] }} - #env: &env_dockerhub_release - # <<: *env_dockerhub - # IMAGE_NAME: iroha env: IMAGE_NAME: iroha steps: @@ -1508,10 +1445,6 @@ jobs: cache-to: type=local,dest=/tmp/.buildx-cache-new tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - # env: - # DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - # DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} - context: docker/release/ push: ${{ steps.docker_login.outcome == 'success' }} - uses: docker/build-push-action@v2 @@ -1523,10 +1456,6 @@ jobs: push: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo == github.event.pull_request.base.repo }} tags: ${{ steps.meta_ghcr.outputs.tags }} labels: ${{ steps.meta_ghcr.outputs.labels }} - # env: - # DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - # DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} - context: docker/release/ - # Temp fix # https://github.com/docker/build-push-action/issues/252 @@ -1537,9 +1466,6 @@ jobs: mv /tmp/.buildx-cache-new /tmp/.buildx-cache docker-D: runs-on: [self-hosted, Linux] #ubuntu-latest - #env: &env_dockerhub_release - # <<: *env_dockerhub - # IMAGE_NAME: iroha env: IMAGE_NAME: iroha steps: @@ -1692,10 +1618,6 @@ jobs: cache-to: type=local,dest=/tmp/.buildx-cache-new tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - # env: - # DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - # DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} - context: docker/release/ push: ${{ steps.docker_login.outcome == 'success' }} - uses: docker/build-push-action@v2 @@ -1707,10 +1629,6 @@ jobs: push: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo == github.event.pull_request.base.repo }} tags: ${{ steps.meta_ghcr.outputs.tags }} labels: ${{ steps.meta_ghcr.outputs.labels }} - # env: - # DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - # DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} - context: docker/release/ - # Temp fix # https://github.com/docker/build-push-action/issues/252 From 8d078047eb41ac4cd858cb6a79936892711b7f7f Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 11:14:56 +0300 Subject: [PATCH 052/130] Add permissions Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 13 ++++++++++++- .github/workflows/build-iroha1-fork.yml | 11 +++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 2337acecdba..d7984fbbcaf 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -1,7 +1,18 @@ name: Iroha1-fork -## This workflow is created for pull requests from forks only and has less permissions than build-iroha1 workflow +permissions: + actions: read + checks: read + contents: read + deployments: read + issues: read + packages: read + pull-requests: read + repository-projects: read + security-events: read + statuses: read +## This workflow is created for pull requests from forks only and has less permissions than build-iroha1 workflow on: pull_request_target: branches: [ main, support/1.*, edge, develop, feature/DOPS-1651/enable-fork-build ] ## target branches diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 47cbd332d18..fc795ad4ef9 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -2,6 +2,17 @@ ## Generated from build-iroha1-fork.src.yml with make-workflows.sh name: Iroha1-fork +permissions: + actions: read + checks: read + contents: read + deployments: read + issues: read + packages: read + pull-requests: read + repository-projects: read + security-events: read + statuses: read ## This workflow is created for pull requests from forks only and has less permissions than build-iroha1 workflow on: pull_request_target: From d06813b8736ae3d7623d90f614ce18a50634c101 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 11:28:30 +0300 Subject: [PATCH 053/130] Fix permissions Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 4 ++-- .github/workflows/build-iroha1-fork.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index d7984fbbcaf..2886829d761 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -4,9 +4,9 @@ permissions: actions: read checks: read contents: read - deployments: read + deployments: write issues: read - packages: read + packages: write pull-requests: read repository-projects: read security-events: read diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index fc795ad4ef9..2e6c5fc577c 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -6,9 +6,9 @@ permissions: actions: read checks: read contents: read - deployments: read + deployments: write issues: read - packages: read + packages: write pull-requests: read repository-projects: read security-events: read From ad04256c9c58350bbe1d1124dc110f3869b35eb6 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 11:37:47 +0300 Subject: [PATCH 054/130] Set none to deployments Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 2 +- .github/workflows/build-iroha1-fork.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 2886829d761..c4995a210d2 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -4,7 +4,7 @@ permissions: actions: read checks: read contents: read - deployments: write + deployments: none issues: read packages: write pull-requests: read diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 2e6c5fc577c..d676a472274 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -6,7 +6,7 @@ permissions: actions: read checks: read contents: read - deployments: write + deployments: none issues: read packages: write pull-requests: read From 6363555c5230b03f8cac11b02d0c994e3cd3d586 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 13:05:09 +0300 Subject: [PATCH 055/130] Update comments, remove odd steps Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 1 + .github/build-iroha1.src.yml | 6 ++---- .github/workflows/build-iroha1-fork.yml | 1 + .github/workflows/build-iroha1.yml | 4 +--- command.sh | 0 5 files changed, 5 insertions(+), 7 deletions(-) delete mode 100644 command.sh diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index c4995a210d2..9e663fe5a42 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -1,5 +1,6 @@ name: Iroha1-fork +# The only write permission requird is packages permissions: actions: read checks: read diff --git a/.github/build-iroha1.src.yml b/.github/build-iroha1.src.yml index 2d20a786e18..a3133098056 100644 --- a/.github/build-iroha1.src.yml +++ b/.github/build-iroha1.src.yml @@ -1,7 +1,7 @@ name: Iroha1 ## IMPORTANT -## This workflow is not run for forks, check build-iroha1-fork for pull_requests from forks +## This workflow does not run for forks, check build-iroha1-fork for pull requests from forks ## TODO IMPORTANT DISALLOW deploying tags and main and develop builds where skip_testing was set. @@ -105,9 +105,7 @@ jobs: ${{ toJson(needs) }} END echo "::endgroup::" - - - run: | - true + ## GitHub Actions Workflow does not support yaml anchors ## and that is why there is a workaround with make-workflows.sh diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index d676a472274..9332c742dc6 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -2,6 +2,7 @@ ## Generated from build-iroha1-fork.src.yml with make-workflows.sh name: Iroha1-fork +# The only write permission requird is packages permissions: actions: read checks: read diff --git a/.github/workflows/build-iroha1.yml b/.github/workflows/build-iroha1.yml index b3d6aeea387..9d0356c4d7f 100644 --- a/.github/workflows/build-iroha1.yml +++ b/.github/workflows/build-iroha1.yml @@ -3,7 +3,7 @@ name: Iroha1 ## IMPORTANT -## This workflow is not run for forks, check build-iroha1-fork for pull_requests from forks +## This workflow does not run for forks, check build-iroha1-fork for pull requests from forks ## TODO IMPORTANT DISALLOW deploying tags and main and develop builds where skip_testing was set. ## TODO 1. [vcpkg,optimization-space,optimization-speed] @@ -102,8 +102,6 @@ jobs: ${{ toJson(needs) }} END echo "::endgroup::" - - run: | - true ## GitHub Actions Workflow does not support yaml anchors ## and that is why there is a workaround with make-workflows.sh ## You should `pre-commit install` or use `pre-commit-hook.sh`, diff --git a/command.sh b/command.sh deleted file mode 100644 index e69de29bb2d..00000000000 From b8ab7090ce7522d4186a42f8fe0481ba5f4e1dc3 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 16:38:31 +0300 Subject: [PATCH 056/130] Not allow changing scripts used in dockerfile Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 4 +++- .github/workflows/build-iroha1-fork.yml | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 9e663fe5a42..23a8cab0cd7 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -48,6 +48,8 @@ jobs: - '.github/**' dockerfile: - '**/Dockerfile' + - 'docker/release/entrypoint.sh' + - 'docker/release/wait-for-it.sh' - name: verify .github folder is not changed if: steps.filter.outputs.github == 'true' @@ -738,7 +740,7 @@ jobs: docker-R: &job_docker_image_release needs: - build-UR - - generate_matrixes + - generate_matrixespackages: write runs-on: [ self-hosted, Linux ] #ubuntu-latest # strategy: *strategy_ubuntu_release # if: *if_ubuntu_release diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 9332c742dc6..ceb335e864b 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -42,6 +42,8 @@ jobs: - '.github/**' dockerfile: - '**/Dockerfile' + - 'docker/release/entrypoint.sh' + - 'docker/release/wait-for-it.sh' - name: verify .github folder is not changed if: steps.filter.outputs.github == 'true' run: | @@ -1297,7 +1299,7 @@ jobs: docker-R: needs: - build-UR - - generate_matrixes + - generate_matrixespackages: write runs-on: [self-hosted, Linux] #ubuntu-latest # strategy: *strategy_ubuntu_release # if: *if_ubuntu_release From b5db2a595f991f922aed446472f6a9503a2b5af1 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 16:57:29 +0300 Subject: [PATCH 057/130] Add new filters Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 8 ++++---- .github/workflows/build-iroha1-fork.yml | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 23a8cab0cd7..1353b70a554 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -45,11 +45,11 @@ jobs: with: filters: | github: - - '.github/**' + - ".github/**" dockerfile: - - '**/Dockerfile' - - 'docker/release/entrypoint.sh' - - 'docker/release/wait-for-it.sh' + - "**/Dockerfile" + - "docker/release/entrypoint.sh" + - "docker/release/wait-for-it.sh" - name: verify .github folder is not changed if: steps.filter.outputs.github == 'true' diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index ceb335e864b..2f2fcc658e5 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -39,11 +39,11 @@ jobs: with: filters: | github: - - '.github/**' + - ".github/**" dockerfile: - - '**/Dockerfile' - - 'docker/release/entrypoint.sh' - - 'docker/release/wait-for-it.sh' + - "**/Dockerfile" + - "docker/release/entrypoint.sh" + - "docker/release/wait-for-it.sh" - name: verify .github folder is not changed if: steps.filter.outputs.github == 'true' run: | From f8869cd53f2390e563ce133cb8137613492e6b79 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 16:58:25 +0300 Subject: [PATCH 058/130] Debug new filters Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 2 +- .github/workflows/build-iroha1-fork.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 1353b70a554..2d84ade6392 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -49,7 +49,7 @@ jobs: dockerfile: - "**/Dockerfile" - "docker/release/entrypoint.sh" - - "docker/release/wait-for-it.sh" + # - "docker/release/wait-for-it.sh" - name: verify .github folder is not changed if: steps.filter.outputs.github == 'true' diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 2f2fcc658e5..002ecf3eec2 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -43,7 +43,7 @@ jobs: dockerfile: - "**/Dockerfile" - "docker/release/entrypoint.sh" - - "docker/release/wait-for-it.sh" + # - "docker/release/wait-for-it.sh" - name: verify .github folder is not changed if: steps.filter.outputs.github == 'true' run: | From 170ca0bba54eb8e61ff29380e59c1721b380b9c3 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 16:59:18 +0300 Subject: [PATCH 059/130] Debug new filters Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 2 +- .github/workflows/build-iroha1-fork.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 2d84ade6392..1969d42509a 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -48,7 +48,7 @@ jobs: - ".github/**" dockerfile: - "**/Dockerfile" - - "docker/release/entrypoint.sh" + # - "docker/release/entrypoint.sh" # - "docker/release/wait-for-it.sh" - name: verify .github folder is not changed diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 002ecf3eec2..4f48e679fd7 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -42,7 +42,7 @@ jobs: - ".github/**" dockerfile: - "**/Dockerfile" - - "docker/release/entrypoint.sh" + # - "docker/release/entrypoint.sh" # - "docker/release/wait-for-it.sh" - name: verify .github folder is not changed if: steps.filter.outputs.github == 'true' From 461f2ecf600b5d3f1c866dc6f6debbc1c977f5b2 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 17:01:09 +0300 Subject: [PATCH 060/130] Debug new filters Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 6 +++--- .github/workflows/build-iroha1-fork.yml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 1969d42509a..532ccf16421 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -48,8 +48,8 @@ jobs: - ".github/**" dockerfile: - "**/Dockerfile" - # - "docker/release/entrypoint.sh" - # - "docker/release/wait-for-it.sh" + - "docker/release/entrypoint.sh" + - "docker/release/wait-for-it.sh" - name: verify .github folder is not changed if: steps.filter.outputs.github == 'true' @@ -740,7 +740,7 @@ jobs: docker-R: &job_docker_image_release needs: - build-UR - - generate_matrixespackages: write + - generate_matrixes runs-on: [ self-hosted, Linux ] #ubuntu-latest # strategy: *strategy_ubuntu_release # if: *if_ubuntu_release diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 4f48e679fd7..f6f7e6548f1 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -42,8 +42,8 @@ jobs: - ".github/**" dockerfile: - "**/Dockerfile" - # - "docker/release/entrypoint.sh" - # - "docker/release/wait-for-it.sh" + - "docker/release/entrypoint.sh" + - "docker/release/wait-for-it.sh" - name: verify .github folder is not changed if: steps.filter.outputs.github == 'true' run: | @@ -1299,7 +1299,7 @@ jobs: docker-R: needs: - build-UR - - generate_matrixespackages: write + - generate_matrixes runs-on: [self-hosted, Linux] #ubuntu-latest # strategy: *strategy_ubuntu_release # if: *if_ubuntu_release From f2fd5af33960a51f3a06ea1eb4a562c4f30b2c36 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Fri, 8 Apr 2022 13:57:28 +0300 Subject: [PATCH 061/130] Refactor to run only by comment Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 35 ++++++++++++++++++++++--- .github/workflows/build-iroha1-fork.yml | 26 +++++++++++++++--- 2 files changed, 53 insertions(+), 8 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 532ccf16421..d719d3e2b71 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -1,6 +1,6 @@ name: Iroha1-fork -# The only write permission requird is packages +# The only write permission required is packages permissions: actions: read checks: read @@ -15,8 +15,12 @@ permissions: ## This workflow is created for pull requests from forks only and has less permissions than build-iroha1 workflow on: - pull_request_target: - branches: [ main, support/1.*, edge, develop, feature/DOPS-1651/enable-fork-build ] ## target branches + #pull_request_target: + # branches: [ main, support/1.*, edge, develop, feature/DOPS-1651/enable-fork-build ] ## target branches + + + issue_comment: + types: [created] env: DOCKERHUB_ORG: hyperledger @@ -24,14 +28,37 @@ env: jobs: + ## This step allows to skip the workflow completely for pull_requests from the same repo ## Also it checks that that .github folder and Dockerfiles are not changed check_if_pull_request_comes_from_fork: + runs-on: ubuntu-20.04 #ubuntu-latest name: Pull requests from forks should use other workflow - if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name }} + if: ${{ github.event.issue.comment.body == "Launch build" }} steps: + - + name: Show context + run: | + echo "::group::GitHub context" + cat <<'END' + ${{ toJson(github) }} + END + echo "::endgroup::" + echo "::group::GitHub needs" + cat <<'END' + ${{ toJson(needs) }} + END + echo "::endgroup::" + + + - name: Allow build + if: + run: | + "Lunching build" + + - &step_checkout_head name: Checkout head uses: actions/checkout@v2 diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index f6f7e6548f1..20f8f77f8a5 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -2,7 +2,7 @@ ## Generated from build-iroha1-fork.src.yml with make-workflows.sh name: Iroha1-fork -# The only write permission requird is packages +# The only write permission required is packages permissions: actions: read checks: read @@ -16,8 +16,10 @@ permissions: statuses: read ## This workflow is created for pull requests from forks only and has less permissions than build-iroha1 workflow on: - pull_request_target: - branches: [main, support/1.*, edge, develop, feature/DOPS-1651/enable-fork-build] ## target branches + #pull_request_target: + # branches: [ main, support/1.*, edge, develop, feature/DOPS-1651/enable-fork-build ] ## target branches + issue_comment: + types: [created] env: DOCKERHUB_ORG: hyperledger jobs: @@ -26,8 +28,24 @@ jobs: check_if_pull_request_comes_from_fork: runs-on: ubuntu-20.04 #ubuntu-latest name: Pull requests from forks should use other workflow - if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name }} + if: ${{ github.event.issue.comment.body == "Launch build" }} steps: + - name: Show context + run: | + echo "::group::GitHub context" + cat <<'END' + ${{ toJson(github) }} + END + echo "::endgroup::" + echo "::group::GitHub needs" + cat <<'END' + ${{ toJson(needs) }} + END + echo "::endgroup::" + - name: Allow build + if: + run: | + "Lunching build" - name: Checkout head uses: actions/checkout@v2 with: From 46c1a6f2a2c6639ad5fde60548a9780485147045 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Fri, 8 Apr 2022 14:03:37 +0300 Subject: [PATCH 062/130] Refactor to run only by comment Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index d719d3e2b71..3e4938c8af9 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -21,6 +21,8 @@ on: issue_comment: types: [created] + branches: [ main, support/1.*, edge, develop, feature/DOPS-1651/enable-fork-build ] + env: DOCKERHUB_ORG: hyperledger From 2adaa4fb79cf84a7a125ed547b20965a3bc19203 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Fri, 8 Apr 2022 14:08:00 +0300 Subject: [PATCH 063/130] Refactor to run only by comment Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 2 +- .github/workflows/build-iroha1-fork.yml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 3e4938c8af9..bb565a3500b 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -21,7 +21,7 @@ on: issue_comment: types: [created] - branches: [ main, support/1.*, edge, develop, feature/DOPS-1651/enable-fork-build ] + branches: [ main, support/1.*, edge, develop, feature/DOPS-1651/enable-fork-build ] env: diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 20f8f77f8a5..86ebadd42d8 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -20,6 +20,7 @@ on: # branches: [ main, support/1.*, edge, develop, feature/DOPS-1651/enable-fork-build ] ## target branches issue_comment: types: [created] + branches: [main, support/1.*, edge, develop, feature/DOPS-1651/enable-fork-build] env: DOCKERHUB_ORG: hyperledger jobs: From 4126e7d9c40acce32e89e6ad7d8a4a1735b56a54 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 13 Apr 2022 13:35:20 +0300 Subject: [PATCH 064/130] Try environments Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 29 +++++++------------------ .github/workflows/build-iroha1-fork.yml | 20 +++++++---------- 2 files changed, 16 insertions(+), 33 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index bb565a3500b..9c7f85efb88 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -15,13 +15,11 @@ permissions: ## This workflow is created for pull requests from forks only and has less permissions than build-iroha1 workflow on: - #pull_request_target: - # branches: [ main, support/1.*, edge, develop, feature/DOPS-1651/enable-fork-build ] ## target branches - - - issue_comment: - types: [created] + pull_request_target: branches: [ main, support/1.*, edge, develop, feature/DOPS-1651/enable-fork-build ] + paths-ignore: + - '**.md' + - '**.rst' env: @@ -29,17 +27,13 @@ env: jobs: - - ## This step allows to skip the workflow completely for pull_requests from the same repo ## Also it checks that that .github folder and Dockerfiles are not changed check_if_pull_request_comes_from_fork: - runs-on: ubuntu-20.04 #ubuntu-latest - name: Pull requests from forks should use other workflow - if: ${{ github.event.issue.comment.body == "Launch build" }} + name: Pull requests from forks should use this workflow + if: github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name steps: - - name: Show context run: | @@ -53,13 +47,6 @@ jobs: ${{ toJson(needs) }} END echo "::endgroup::" - - - - name: Allow build - if: - run: | - "Lunching build" - - &step_checkout_head name: Checkout head @@ -94,9 +81,9 @@ jobs: generate_matrixes: - runs-on: ubuntu-20.04 #ubuntu-latest + environment: test-env + runs-on: ubuntu-20.04 needs: check_if_pull_request_comes_from_fork - #container: ubuntu:latest if: ${{ (github.event_name != 'comment') || ( github.event.comment && github.event.issue.pull_request && startsWith(github.event.comment.body, '/build') ) }} diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 86ebadd42d8..70401cda312 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -16,11 +16,11 @@ permissions: statuses: read ## This workflow is created for pull requests from forks only and has less permissions than build-iroha1 workflow on: - #pull_request_target: - # branches: [ main, support/1.*, edge, develop, feature/DOPS-1651/enable-fork-build ] ## target branches - issue_comment: - types: [created] + pull_request_target: branches: [main, support/1.*, edge, develop, feature/DOPS-1651/enable-fork-build] + paths-ignore: + - '**.md' + - '**.rst' env: DOCKERHUB_ORG: hyperledger jobs: @@ -28,8 +28,8 @@ jobs: ## Also it checks that that .github folder and Dockerfiles are not changed check_if_pull_request_comes_from_fork: runs-on: ubuntu-20.04 #ubuntu-latest - name: Pull requests from forks should use other workflow - if: ${{ github.event.issue.comment.body == "Launch build" }} + name: Pull requests from forks should use this workflow + if: github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name steps: - name: Show context run: | @@ -43,10 +43,6 @@ jobs: ${{ toJson(needs) }} END echo "::endgroup::" - - name: Allow build - if: - run: | - "Lunching build" - name: Checkout head uses: actions/checkout@v2 with: @@ -74,9 +70,9 @@ jobs: echo "Pull requests from forks are not allowed to change Dockerfiles" false generate_matrixes: - runs-on: ubuntu-20.04 #ubuntu-latest + environment: test-env + runs-on: ubuntu-20.04 needs: check_if_pull_request_comes_from_fork - #container: ubuntu:latest if: ${{ (github.event_name != 'comment') || ( github.event.comment && github.event.issue.pull_request && startsWith(github.event.comment.body, '/build') ) }} steps: - name: Show context From 983f9c6d0ab584e0544aaa0e12b9b4caca1ae8cc Mon Sep 17 00:00:00 2001 From: safinsaf Date: Tue, 29 Mar 2022 13:30:24 +0300 Subject: [PATCH 065/130] Add new workflow for forks Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 605 ++++++++++++++++++++++ .github/workflows/build-iroha1-fork.yml | 650 ++++++++++++++++++++++++ 2 files changed, 1255 insertions(+) create mode 100644 .github/build-iroha1-fork.src.yml create mode 100644 .github/workflows/build-iroha1-fork.yml diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml new file mode 100644 index 00000000000..29e42425420 --- /dev/null +++ b/.github/build-iroha1-fork.src.yml @@ -0,0 +1,605 @@ +name: Iroha1-fork + +on: + pull_request_target: + branches: [ feature/DOPS-1651/enable-fork-build ] ## target branches + +env: + DOCKERHUB_ORG: hyperledger + +jobs: + ## GitHub Actions Workflow does not support yaml anchors + ## and that is why there is a workaround with make-workflows.sh + ## You should `pre-commit install` or use `pre-commit-hook.sh`, + ## anyway please read .github/README.md + check_workflow_yaml_coressponds_to_src_yaml: + runs-on: ubuntu-20.04 #ubuntu-latest + name: Check if github workflows were properly made from sources + steps: + - &step_show_context + name: Show context + run: | + echo "::group::GitHub context" + cat <<'END' + ${{ toJson(github) }} + END + echo "::endgroup::" + echo "::group::GitHub needs" + cat <<'END' + ${{ toJson(needs) }} + END + echo "::endgroup::" + - &step_detect_commented_pr + name: REF and SHA of commented PR to ENV + if: github.event.comment + run: > + curl -fsSL ${{github.event.issue.pull_request.url}} + -H "Authorization: token ${{github.token}}" | + jq -r ' + "PR_REF="+.head.ref, + "PR_SHA="+.head.sha, + "PR_NUM="+(.number|tostring), + "PR_REPO="+.head.repo.full_name' >>$GITHUB_ENV + - *step_show_context + - &step_checkout_base + name: Checkout base + uses: actions/checkout@v2 + with: &step_checkout_with_base + ref: ${{env.PR_REF}} ## not empty on issue_comment, else default value GITHUB_REF + repository: ${{env.PR_REPO}} ## not empty on issue_comment, else default value github.repository, required by forks + - + run: sudo snap install yq + - + name: Check if .github/workflows/*.yml correspond to *.src.yml + run: | + set -x + [[ $(./.github/make-workflows.sh -x --worktree) = *"everything is up to date" ]] + + + generate_matrixes: + runs-on: ubuntu-20.04 #ubuntu-latest + #container: ubuntu:latest + if: ${{ (github.event_name != 'comment') || ( github.event.comment && + github.event.issue.pull_request && + startsWith(github.event.comment.body, '/build') ) }} + steps: + - *step_show_context + - *step_detect_commented_pr + - *step_checkout_base + - + name: Generate matrix for build triggered by chat-ops - comment to PR + if: github.event.issue.pull_request && github.event.comment + id: comment_body + run: echo "${{github.event.comment.body}}" >/tmp/comment_body + - + name: Generate default matrix for regular builds + if: ${{ steps.comment_body.outcome == 'skipped' }} ## i.e. not github.event.issue.pull_request + run: | + set -x + git fetch origin ${{github.event.pull_request.head.sha}} --depth=2 ## depth=2 to detect if fetched commit is merge commit + git log -1 FETCH_HEAD + commit_message_body_build_spec(){ + git log -n1 $1 --format=%B | grep '^/build ' + } + git_is_merge_commit(){ + git rev-parse ${1:-HEAD}^2 &>/dev/null + } + commit_was_merged_build_spec(){ + git_is_merge_commit $1 && + git log -n1 $1 --format=%s | grep -q '^Merge branch' && + echo "/build before-merge" + } + case ${{github.event_name}} in + pull_request_target) if commit_message_body_build_spec FETCH_HEAD >/tmp/comment_body ;then + if git_is_merge_commit FETCH_HEAD ;then + echo ::warning::'/build directive in merge commit overrides default "/build before-merge"' + fi + elif commit_was_merged_build_spec FETCH_HEAD >/tmp/comment_body ;then + true + else + #echo >/tmp/comment_body "/build debug; /build ubuntu release debug normal" + #echo >/tmp/comment_body "/build all" + echo >/tmp/comment_body "/build ubuntu debug clang-10 normal" + fi ;; + esac + - + name: Generate matrixes + id: matrixes + run: | + set -x + cat /tmp/comment_body | .github/chatops-gen-matrix.sh + echo "::set-output name=matrix_ubuntu::$(cat matrix_ubuntu)" + echo "::set-output name=matrix_ubuntu_release::$(cat matrix_ubuntu_release)" + echo "::set-output name=matrix_ubuntu_debug::$(cat matrix_ubuntu_debug)" + echo "::set-output name=matrix_macos::$(cat matrix_macos)" + echo "::set-output name=matrix_windows::$(cat matrix_windows)" + echo "::set-output name=matrix_dockerimage_release::$(cat matrix_dockerimage_release)" + echo "::set-output name=matrix_dockerimage_debug::$(cat matrix_dockerimage_debug)" + ##TODO report errors and warnings as answer to issue comment (chat-ops) + - + name: Reaction confused + if: failure() && github.event.comment + run: | + # send reaction to comment to show build was triggered + curl ${{github.event.comment.url}}/reactions \ + -X POST \ + -d '{"content":"confused"}' \ + -H "Accept: application/vnd.github.squirrel-girl-preview+json" \ + -H "Authorization: token ${{github.token}}" + - + name: Reaction rocket + if: github.event.comment + run: | + # send reaction to comment to show build was triggered + curl ${{github.event.comment.url}}/reactions \ + -X POST \ + -d '{"content":"rocket"}' \ + -H "Accept: application/vnd.github.squirrel-girl-preview+json" \ + -H "Authorization: token ${{github.token}}" + outputs: + matrix_ubuntu: ${{steps.matrixes.outputs.matrix_ubuntu}} + matrix_ubuntu_release: ${{steps.matrixes.outputs.matrix_ubuntu_release}} + matrix_ubuntu_debug: ${{steps.matrixes.outputs.matrix_ubuntu_debug}} + matrix_macos: ${{steps.matrixes.outputs.matrix_macos}} + matrix_windows: ${{steps.matrixes.outputs.matrix_windows}} + matrix_dockerimage_release: ${{steps.matrixes.outputs.matrix_dockerimage_release}} + matrix_dockerimage_debug: ${{steps.matrixes.outputs.matrix_dockerimage_debug}} + + Docker-iroha-builder: + needs: check_workflow_yaml_coressponds_to_src_yaml + runs-on: ubuntu-20.04 #ubuntu-latest #[ self-hosted, Linux ] + # env: &env_dockerhub + # DOCKERHUB_ORG: DOCKERHUB_ORG ## Must be hyperledger, also can use iroha1, cannot use ${{ secrets.DOCKERHUB_ORG }} + # DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + # DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + steps: + - *step_show_context + - &step_system_info + name: System info + run: | + set -x + whoami + id $(whoami) + free || vm_stat | perl -ne '/page size of (\d+)/ and $size=$1; + /Pages\s+([^:]+)[^\d]+(\d+)/ and printf("%-16s % 16.2f Mi\n", "$1:", $2 * $size / 1048576);' + df -h + - &step_build_info + name: Build info + run: | + cat << 'END' + ref:${{github.ref}} + sha:${{github.sha}} + run_number:${{github.run_number}} + event_name:${{github.event_name}} + event.action:${{github.event.action}} + event.issue.number:${{ github.event.issue.number }} + END + - *step_detect_commented_pr + - &step_checkout_head + name: Checkout head + uses: actions/checkout@v2 + with: &step_checkout_with_head + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} + - &step_docker_tag + name: Determine dockertag + id: dockertag + env: + dockertag: ${{ hashFiles('docker/iroha-builder/**') }} + run: | + echo "::set-output name=dockertag::$dockertag" + echo >>$GITHUB_ENV dockertag=$dockertag + test -n "$DOCKERHUB_ORG" || { + echo ::error::"DOCKERHUB_ORG must contain value" + false + } + - &step_docker_login + name: Login to DockerHub + #if: ${{ secrets.DOCKERHUB_TOKEN != '' && secrets.DOCKERHUB_USERNAME != '' }} + id: docker_login + uses: docker/login-action@v1 + with: + #username: ${{ secrets.DOCKERHUB_USERNAME }} + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - &step_docker_login_ghcr + name: Log in to the Container registry GHCR + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - &step_warn_docker_no_push + name: Possible WARNING + if: ${{ steps.docker_login.outcome == 'skipped' }} + run: echo "::warning::DOCKERHUB_TOKEN and DOCKERHUB_USERNAME are empty. Will build but NOT push." + - &step_docker_meta + name: Docker meta + id: meta + uses: docker/metadata-action@v3 + with: &step_docker_meta_with + images: ${{ env.DOCKERHUB_ORG }}/iroha-builder + tags: | + type=raw,value=${{env.dockertag}} + type=ref,event=branch + type=ref,event=pr + type=ref,event=tag + type=schedule + ## Docker image will be pushed with tags: + ## - hash of file Dockerfile.builder + ## - branchname, when branch is pushed + ## - pr-NUMBER, when pushed to PR + ## - git tag when tag is pushed + ## - schedule, see the docs + - &step_docker_meta_ghcr + <<: *step_docker_meta + name: Docker meta GHCR + id: meta_ghcr + with: + <<: *step_docker_meta_with + images: ghcr.io/${{ github.repository }}-builder + - &step_docker_buildx + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - &step_docker_cache + name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{env.dockertag}} + restore-keys: ${{ runner.os }}-buildx- + - &step_docker_build_and_push + id: build_and_push + name: Build and push + uses: docker/build-push-action@v2 + with: &step_docker_build_and_push_with + context: docker/iroha-builder/ + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new + push: ${{ steps.docker_login.outcome == 'success' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + # env: + # DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + # DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + - &step_docker_build_and_push_ghcr + <<: *step_docker_build_and_push + id: build_and_push_ghcr + name: Build and push to GHCR + with: &step_docker_build_and_push_ghcr-with + <<: *step_docker_build_and_push_with + push: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo == github.event.pull_request.base.repo }} + tags: ${{ steps.meta_ghcr.outputs.tags }} + labels: ${{ steps.meta_ghcr.outputs.labels }} + # env: + # DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + # DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + - &step_docker_move_cache + # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache + - + name: Check if dockertaghash exists in remote registry + id: dockertag_already + run: | + echo "::set-output name=container::$DOCKERHUB_ORG/iroha-builder:$dockertag" + docker pull "$DOCKERHUB_ORG/iroha-builder:$dockertag" + - + name: Possible ERROR, Dockerfile edited, image was build, but seems not pushed, CANNOT PULL. + if: failure() + #if: ${{ steps.docker_login.outcome != 'success' || steps.build_and_push.outcome != 'success' }} + env: + container: ${{steps.dockertag_already.outputs.container}} + dockertag: ${{env.dockertag}} + run: | + cat </dev/null <<'END' + ${{ toJson(needs) }} + END + - + env: + container: *container_image + run: test -n "$container" + - *step_system_info + - *step_build_info + - &step_env_from_buildspec + name: export CC,BuildType from matrix.buildspec + run: | + echo >>$GITHUB_ENV OS=$(echo ${{matrix.buildspec}} | awk '{print $1}') + echo >>$GITHUB_ENV CC_NAME=$(echo ${{matrix.buildspec}} | awk '{print $2}') + echo >>$GITHUB_ENV BuildType=$(echo ${{matrix.buildspec}} | awk '{print $3}') + features=$(echo ${{matrix.buildspec}} | awk '{print $4}') + case $features in + normal) echo >>$GITHUB_ENV CMAKE_USE=""; features= ;; + ursa) echo >>$GITHUB_ENV CMAKE_USE="-DUSE_LIBURSA=ON";; + burrow) echo >>$GITHUB_ENV CMAKE_USE="-DUSE_BURROW=ON";; + *) echo "::error::Unknown features '$features'"; false ;; + esac + echo >>$GITHUB_ENV features="$features" + echo >>$GITHUB_ENV skip_testing=$(echo ${{matrix.buildspec}} | grep -Fo skip_testing) + - *step_detect_commented_pr + - &step_checkout_full + <<: *step_checkout_head + with: + <<: *step_checkout_with_head + fetch-depth: 0 ## full history + - &step_export_cxx + name: export CC and CXX + env: &step_export_cxx_env + CCACHE_PATH: /usr/lib/ccache + run: | + set -xeu #o pipefail + if test $CC_NAME = llvm + then CC=/usr/local/opt/llvm/bin/clang + else CC=$CC_NAME + fi + echo >>$GITHUB_ENV CC=$CC + echo >>$GITHUB_ENV CXX=$(echo $CC | sed -es,gcc,g++, -es,clang,clang++,) + echo >>$GITHUB_PATH $CCACHE_PATH + ls -lA $CCACHE_PATH + $(realpath $CCACHE_PATH/gcc) --show-config + echo >>$GITHUB_ENV _CCACHE_DIR=$($(realpath $CCACHE_PATH/gcc) --show-config | sed -nE 's,.*cache_dir = ,,p') + echo >>$GITHUB_ENV NPROC=$(nproc | awk '{printf("%.0f",$1*0.77)}') + echo >>$GITHUB_ENV HOME=$HOME + - &step_restore_ccache + name: Restore cache CCache + uses: actions/cache@v2 + with: + path: ${{ env._CCACHE_DIR }} + key: ${{runner.os}}-ccache-${{ github.event.pull_request.head.sha }} + restore-keys: ${{runner.os}}-ccache- + - &step_store_ccache_stats + run: ccache --show-stats | tee /tmp/ccache-stats + - &step_vcpkg_cache + ## Read the docs https://vcpkg.readthedocs.io/en/latest/users/binarycaching/ https://github.com/microsoft/vcpkg/blob/master/docs/users/binarycaching.md + name: Restore cache Vcpkg binarycache ## NOTE not useng NuGet because on ubuntu nuget needs mono of 433MB, unusable. + uses: actions/cache@v2 + with: + path: | + ${{env.HOME}}/.cache/vcpkg/archives + key: ${{runner.os}}-vcpkg-${{env.CC_NAME}}.${{ hashFiles('vcpkg/**') }} + restore-keys: ${{runner.os}}-vcpkg-${{env.CC_NAME}}. + - &step_vcpkg_build + name: Build iroha vcpkg dependancies + run: ./vcpkg/build_iroha_deps.sh $PWD/vcpkg-build; test -f $PWD/vcpkg-build/scripts/buildsystems/vcpkg.cmake + ## Takes 48m16s on default GitHub runner with 2 cores + ## Takes 13m41s on self-hosted AWS EC2 c5.x4large + # ________________________________________________________ + # Executed in 32,08 mins fish external + # usr time 110,52 mins 0,24 millis 110,52 mins + # sys time 12,26 mins 1,34 millis 12,26 mins + # + # All requested packages are currently installed. + # ________________________________________________________ + # Executed in 3,17 secs fish external + # usr time 2,05 secs 128,00 micros 2,05 secs + # sys time 0,70 secs 575,00 micros 0,70 secs + - &step_cmake_configure + name: CMake configure + ## Takes 13s on regular GitHub runner + run: cmake -B build -DCMAKE_TOOLCHAIN_FILE=$PWD/vcpkg-build/scripts/buildsystems/vcpkg.cmake + -DCMAKE_BUILD_TYPE=${{ env.BuildType }} + -GNinja + $CMAKE_USE + -DTESTING=$( test "$skip_testing" = skip_testing && echo OFF || echo ON ) + -DBENCHMARKING=$( test "$skip_testing" = skip_testing && echo OFF || echo ON ) + -DPACKAGE_DEB=ON + #-DCMAKE_VERBOSE_MAKEFILE=ON ## Note: use for debug + - &step_cmake_build + name: CMake build + run: | + set -x + ## reduce memory usage to do not overflow + cmake --build build --config ${{ env.BuildType }} -- -j$(nproc | awk '{printf("%.0f",$1*0.77)}') + echo ::notice::"$(./build/bin/irohad --version)" + ## Debug takes 18m44s on regular GitHub runner + ## Debug takes 7m41s on self-hosted AWS EC2 c5.x4large + ## Release takes 2m58s on self-hosted AWS EC2 c5.x4large + - &step_cpack + name: CPack (linux only) + run: cd build; cpack; ## cmake --build build --target package + - &step_compare_ccache_stats + run: ccache --show-stats | diff --side-by-side /tmp/ccache-stats - ||true + - &step_always_after_build + name: Show free space and disk usage + if: ${{ always() }} + run: | + df -h || true + - &step_artifact_suffix + name: Generate artifact suffix depending on matrix to env.ARTIFACT_SUFFIX + run: | + set -x + cc=$(echo $CC_NAME | sed -Ee's,[-/],,g' ) + build_type=$(echo $BuildType | tr A-Z a-z | sed -E -es,debug,dbg, -es,release,rel, ) + test $build_type = dbg -o $build_type = rel + uses=$(echo "$features" | tr ' ' - | tr A-Z a-z) + _os=${OS:+-$OS} _cc=${cc:+-$cc} _build_type=${build_type:+-$build_type} _uses=${uses:+-$uses} + echo >>$GITHUB_ENV ARTIFACT_SUFFIX=$_os$_cc$_build_type$_uses + echo >>$GITHUB_ENV _uses_suffix=$_uses + echo >>$GITHUB_ENV _compiler_suffix=$(test $cc != gcc9 && echo $_cc) + echo >>$GITHUB_ENV _debug_suffix=$(test "$build_type" = dbg && echo -debug || true) + - &step_artifact_irohad + name: Upload artifact irohad + uses: actions/upload-artifact@v2 + with: + name: irohad${{env.ARTIFACT_SUFFIX}} + path: &step_artifact_irohad_path | + build/bin/irohad + build/bin/iroha-cli + - &step_artifact_iroha_deb + name: Upload artifact iroha-deb + uses: actions/upload-artifact@v2 + with: + name: iroha-deb${{env.ARTIFACT_SUFFIX}} + path: &step_artifact_iroha_deb_path | + build/*.deb + - &step_artifact_tests + if: ${{ false }} ## Maybe test in another job + name: Upload artifact tests + uses: actions/upload-artifact@v2 + with: + name: iroha-tests-ubuntu${{env.ARTIFACT_SUFFIX}} + path: | + build/test_bin/** + build/test_data/** + - &step_ctest + timeout-minutes: 40 + if: env.skip_testing == '' + name: CTest + run: | + echo ::group::'boilerplate' + set -euo pipefail + if test $(uname) = Darwin ;then + ## This is a common portable solution, but Debian and Ubuntu have their own wrappers + initdb --locale=C --encoding=UTF-8 --username=postgres $PWD/postgres_database + postgres -D $PWD/postgres_database -p5432 2>&1 >/tmp/postgres.log & { sleep .3; kill -0 $!; } ## use pg_ctl no need & + else ## Debian or Ubuntu + ## Need to go debian-specific way because + ## initdb is not allowed to be run as root, but we need to run as root + ## because GitHub actions runners have much issues with permissions. + mkdir postgres_database && chown iroha-ci postgres_database + echo /usr/lib/postgresql/12/bin/initdb --locale=C --encoding=UTF-8 --username=postgres $PWD/postgres_database | su iroha-ci + echo /usr/lib/postgresql/12/bin/pg_ctl start -D $PWD/postgres_database --log=$PWD/postgres_database/log | su iroha-ci + # ## Need to go debian-specific way because + # ## initdb is not allowed to be run as root, but we need to run as root + # ## because GitHub actions runners have much issues with permissions. + # cat </etc/postgresql/12/main/pg_hba.conf + # # TYPE DATABASE USER ADDRESS METHOD + # local all all trust + # host all all 127.0.0.1/32 trust + # host all all ::1/128 trust + # local replication all trust + # host replication all 127.0.0.1/32 trust + # host replication all ::1/128 trust + # END + # pg_ctlcluster 12 main start ## Cluster 'main' exist by default + # #OR pg_createcluster -p 5432 --start 12 iroha -- --locale=C --encoding=UTF-8 --username=postgres + fi + cd build + + ## This is just a small lifehack to TEMPORARY allow some tests to fail + cat ../.github/TESTS_ALLOWED_TO_FAIL | sort -u >ALLOW_TO_FAIL || true + + if test -e ALLOW_TO_FAIL + then echo "::warning:: There are TESTS_ALLOWED_TO_FAIL: "$(cat ALLOW_TO_FAIL) + fi + + grep_failed_tests(){ + grep 'The following tests FAILED:' -A10000 "$@" | tail +2 #| cut -d- -f2 | cut -d' ' -f2 | sort + } + exclude_allowed_to_fail(){ + grep -Fvf ALLOW_TO_FAIL "$@" + } + only_allowed_to_fail(){ + grep -Ff ALLOW_TO_FAIL "$@" + } + list_to_line(){ + comma='' + while read N d name sta ;do + echo -n "$comma$N-$name$sta" + comma=', ' + done + } + echo ::endgroup:: + + ## Run module_* tests in parallel and others subsequently + ## Cathgories sorted in order of importancy + CTEST_CATHEGORIES=( module tool framework regression system integration ) + ## Add rest available cathgories + CTEST_CATHEGORIES+=( $( + ctest --show-only=json-v1 -R "^(module|tool|framework|regression|system|integration)" | + jq -r .tests[].name | + cut -f1 -d_ | + sort -u | + grep -Fvf <( printf '%s\n' ${CTEST_CATHEGORIES[@]} ) + ) + ) || true + CTEST_DEFAULT_timeout=80 + CTEST_module_timeout=120 CTEST_module_parallel=4 + CTEST_tool_timeout=200 + CTEST_integration_timeout=120 + CTEST_integration_args='--repeat until-pass:10' ## FIXME remove this hack + CTEST_system_args='--repeat until-pass:10' ## FIXME remove this hack + + for cathegory in ${CTEST_CATHEGORIES[@]} ;do + echo >&2 ::group::"$cathegory tests" + set -x + timeout_name=CTEST_${cathegory}_timeout; timeout=${!timeout_name:-$CTEST_DEFAULT_timeout} + parallel_name=CTEST_${cathegory}_parallel; parallel=${!parallel_name:-} + args_name=CTEST_${cathegory}_args; args=${!args_name:-} + ctest -R "^${cathegory}_" ${parallel:+--parallel $parallel} --output-on-failure --no-tests=error --timeout $timeout ${args:-} \ + | tee ctest_$cathegory.out \ + || true + set +x + echo >&2 ::endgroup:: + done + + tests_passed=true + for t in ${CTEST_CATHEGORIES[@]} ;do + f=ctest_$t.out + if a=$(grep_failed_tests $f | exclude_allowed_to_fail | list_to_line) ;then + echo "::error::The following $(echo $t | tr a-z A-Z) tests FAILED but not in list ALLOW_TO_FAIL: $a" + tests_passed=false + fi + if o=$(grep_failed_tests $f | only_allowed_to_fail | list_to_line) ;then + echo "::warning::The following $t tests FAILED and ALLOWED TO FAIL: $o" + fi + done + $tests_passed diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml new file mode 100644 index 00000000000..dc2a8be67c3 --- /dev/null +++ b/.github/workflows/build-iroha1-fork.yml @@ -0,0 +1,650 @@ +## DO NOT EDIT +## Generated from build-iroha1-fork.src.yml with make-workflows.sh + +name: Iroha1-fork +on: + pull_request_target: + branches: [feature/DOPS-1651/enable-fork-build] ## target branches +env: + DOCKERHUB_ORG: hyperledger +jobs: + ## GitHub Actions Workflow does not support yaml anchors + ## and that is why there is a workaround with make-workflows.sh + ## You should `pre-commit install` or use `pre-commit-hook.sh`, + ## anyway please read .github/README.md + check_workflow_yaml_coressponds_to_src_yaml: + runs-on: ubuntu-20.04 #ubuntu-latest + name: Check if github workflows were properly made from sources + steps: + - name: Show context + run: | + echo "::group::GitHub context" + cat <<'END' + ${{ toJson(github) }} + END + echo "::endgroup::" + echo "::group::GitHub needs" + cat <<'END' + ${{ toJson(needs) }} + END + echo "::endgroup::" + - name: REF and SHA of commented PR to ENV + if: github.event.comment + run: > + curl -fsSL ${{github.event.issue.pull_request.url}} -H "Authorization: token ${{github.token}}" | jq -r ' + + "PR_REF="+.head.ref, + "PR_SHA="+.head.sha, + "PR_NUM="+(.number|tostring), + "PR_REPO="+.head.repo.full_name' >>$GITHUB_ENV + - name: Show context + run: | + echo "::group::GitHub context" + cat <<'END' + ${{ toJson(github) }} + END + echo "::endgroup::" + echo "::group::GitHub needs" + cat <<'END' + ${{ toJson(needs) }} + END + echo "::endgroup::" + - name: Checkout base + uses: actions/checkout@v2 + with: + ref: ${{env.PR_REF}} ## not empty on issue_comment, else default value GITHUB_REF + repository: ${{env.PR_REPO}} ## not empty on issue_comment, else default value github.repository, required by forks + - run: sudo snap install yq + - name: Check if .github/workflows/*.yml correspond to *.src.yml + run: | + set -x + [[ $(./.github/make-workflows.sh -x --worktree) = *"everything is up to date" ]] + generate_matrixes: + runs-on: ubuntu-20.04 #ubuntu-latest + #container: ubuntu:latest + if: ${{ (github.event_name != 'comment') || ( github.event.comment && github.event.issue.pull_request && startsWith(github.event.comment.body, '/build') ) }} + steps: + - name: Show context + run: | + echo "::group::GitHub context" + cat <<'END' + ${{ toJson(github) }} + END + echo "::endgroup::" + echo "::group::GitHub needs" + cat <<'END' + ${{ toJson(needs) }} + END + echo "::endgroup::" + - name: REF and SHA of commented PR to ENV + if: github.event.comment + run: > + curl -fsSL ${{github.event.issue.pull_request.url}} -H "Authorization: token ${{github.token}}" | jq -r ' + + "PR_REF="+.head.ref, + "PR_SHA="+.head.sha, + "PR_NUM="+(.number|tostring), + "PR_REPO="+.head.repo.full_name' >>$GITHUB_ENV + - name: Checkout base + uses: actions/checkout@v2 + with: + ref: ${{env.PR_REF}} ## not empty on issue_comment, else default value GITHUB_REF + repository: ${{env.PR_REPO}} ## not empty on issue_comment, else default value github.repository, required by forks + - name: Generate matrix for build triggered by chat-ops - comment to PR + if: github.event.issue.pull_request && github.event.comment + id: comment_body + run: echo "${{github.event.comment.body}}" >/tmp/comment_body + - name: Generate default matrix for regular builds + if: ${{ steps.comment_body.outcome == 'skipped' }} ## i.e. not github.event.issue.pull_request + run: | + set -x + git fetch origin ${{github.event.pull_request.head.sha}} --depth=2 ## depth=2 to detect if fetched commit is merge commit + git log -1 FETCH_HEAD + commit_message_body_build_spec(){ + git log -n1 $1 --format=%B | grep '^/build ' + } + git_is_merge_commit(){ + git rev-parse ${1:-HEAD}^2 &>/dev/null + } + commit_was_merged_build_spec(){ + git_is_merge_commit $1 && + git log -n1 $1 --format=%s | grep -q '^Merge branch' && + echo "/build before-merge" + } + case ${{github.event_name}} in + pull_request_target) if commit_message_body_build_spec FETCH_HEAD >/tmp/comment_body ;then + if git_is_merge_commit FETCH_HEAD ;then + echo ::warning::'/build directive in merge commit overrides default "/build before-merge"' + fi + elif commit_was_merged_build_spec FETCH_HEAD >/tmp/comment_body ;then + true + else + #echo >/tmp/comment_body "/build debug; /build ubuntu release debug normal" + #echo >/tmp/comment_body "/build all" + echo >/tmp/comment_body "/build ubuntu debug clang-10 normal" + fi ;; + esac + - name: Generate matrixes + id: matrixes + run: | + set -x + cat /tmp/comment_body | .github/chatops-gen-matrix.sh + echo "::set-output name=matrix_ubuntu::$(cat matrix_ubuntu)" + echo "::set-output name=matrix_ubuntu_release::$(cat matrix_ubuntu_release)" + echo "::set-output name=matrix_ubuntu_debug::$(cat matrix_ubuntu_debug)" + echo "::set-output name=matrix_macos::$(cat matrix_macos)" + echo "::set-output name=matrix_windows::$(cat matrix_windows)" + echo "::set-output name=matrix_dockerimage_release::$(cat matrix_dockerimage_release)" + echo "::set-output name=matrix_dockerimage_debug::$(cat matrix_dockerimage_debug)" + ##TODO report errors and warnings as answer to issue comment (chat-ops) + - name: Reaction confused + if: failure() && github.event.comment + run: | + # send reaction to comment to show build was triggered + curl ${{github.event.comment.url}}/reactions \ + -X POST \ + -d '{"content":"confused"}' \ + -H "Accept: application/vnd.github.squirrel-girl-preview+json" \ + -H "Authorization: token ${{github.token}}" + - name: Reaction rocket + if: github.event.comment + run: | + # send reaction to comment to show build was triggered + curl ${{github.event.comment.url}}/reactions \ + -X POST \ + -d '{"content":"rocket"}' \ + -H "Accept: application/vnd.github.squirrel-girl-preview+json" \ + -H "Authorization: token ${{github.token}}" + outputs: + matrix_ubuntu: ${{steps.matrixes.outputs.matrix_ubuntu}} + matrix_ubuntu_release: ${{steps.matrixes.outputs.matrix_ubuntu_release}} + matrix_ubuntu_debug: ${{steps.matrixes.outputs.matrix_ubuntu_debug}} + matrix_macos: ${{steps.matrixes.outputs.matrix_macos}} + matrix_windows: ${{steps.matrixes.outputs.matrix_windows}} + matrix_dockerimage_release: ${{steps.matrixes.outputs.matrix_dockerimage_release}} + matrix_dockerimage_debug: ${{steps.matrixes.outputs.matrix_dockerimage_debug}} + Docker-iroha-builder: + needs: check_workflow_yaml_coressponds_to_src_yaml + runs-on: ubuntu-20.04 #ubuntu-latest #[ self-hosted, Linux ] + # env: &env_dockerhub + # DOCKERHUB_ORG: DOCKERHUB_ORG ## Must be hyperledger, also can use iroha1, cannot use ${{ secrets.DOCKERHUB_ORG }} + # DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + # DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + steps: + - name: Show context + run: | + echo "::group::GitHub context" + cat <<'END' + ${{ toJson(github) }} + END + echo "::endgroup::" + echo "::group::GitHub needs" + cat <<'END' + ${{ toJson(needs) }} + END + echo "::endgroup::" + - name: System info + run: | + set -x + whoami + id $(whoami) + free || vm_stat | perl -ne '/page size of (\d+)/ and $size=$1; + /Pages\s+([^:]+)[^\d]+(\d+)/ and printf("%-16s % 16.2f Mi\n", "$1:", $2 * $size / 1048576);' + df -h + - name: Build info + run: | + cat << 'END' + ref:${{github.ref}} + sha:${{github.sha}} + run_number:${{github.run_number}} + event_name:${{github.event_name}} + event.action:${{github.event.action}} + event.issue.number:${{ github.event.issue.number }} + END + - name: REF and SHA of commented PR to ENV + if: github.event.comment + run: > + curl -fsSL ${{github.event.issue.pull_request.url}} -H "Authorization: token ${{github.token}}" | jq -r ' + + "PR_REF="+.head.ref, + "PR_SHA="+.head.sha, + "PR_NUM="+(.number|tostring), + "PR_REPO="+.head.repo.full_name' >>$GITHUB_ENV + - name: Checkout head + uses: actions/checkout@v2 + with: + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} + - name: Determine dockertag + id: dockertag + env: + dockertag: ${{ hashFiles('docker/iroha-builder/**') }} + run: | + echo "::set-output name=dockertag::$dockertag" + echo >>$GITHUB_ENV dockertag=$dockertag + test -n "$DOCKERHUB_ORG" || { + echo ::error::"DOCKERHUB_ORG must contain value" + false + } + - name: Login to DockerHub + #if: ${{ secrets.DOCKERHUB_TOKEN != '' && secrets.DOCKERHUB_USERNAME != '' }} + id: docker_login + uses: docker/login-action@v1 + with: + #username: ${{ secrets.DOCKERHUB_USERNAME }} + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Log in to the Container registry GHCR + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Possible WARNING + if: ${{ steps.docker_login.outcome == 'skipped' }} + run: echo "::warning::DOCKERHUB_TOKEN and DOCKERHUB_USERNAME are empty. Will build but NOT push." + - name: Docker meta + id: meta + uses: docker/metadata-action@v3 + with: + images: ${{ env.DOCKERHUB_ORG }}/iroha-builder + tags: | + type=raw,value=${{env.dockertag}} + type=ref,event=branch + type=ref,event=pr + type=ref,event=tag + type=schedule + ## Docker image will be pushed with tags: + ## - hash of file Dockerfile.builder + ## - branchname, when branch is pushed + ## - pr-NUMBER, when pushed to PR + ## - git tag when tag is pushed + ## - schedule, see the docs + - uses: docker/metadata-action@v3 + name: Docker meta GHCR + id: meta_ghcr + with: + tags: | + type=raw,value=${{env.dockertag}} + type=ref,event=branch + type=ref,event=pr + type=ref,event=tag + type=schedule + ## Docker image will be pushed with tags: + ## - hash of file Dockerfile.builder + ## - branchname, when branch is pushed + ## - pr-NUMBER, when pushed to PR + ## - git tag when tag is pushed + ## - schedule, see the docs + + images: ghcr.io/${{ github.repository }}-builder + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{env.dockertag}} + restore-keys: ${{ runner.os }}-buildx- + - id: build_and_push + name: Build and push + uses: docker/build-push-action@v2 + with: + context: docker/iroha-builder/ + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new + push: ${{ steps.docker_login.outcome == 'success' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + # env: + # DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + # DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + - uses: docker/build-push-action@v2 + id: build_and_push_ghcr + name: Build and push to GHCR + with: + context: docker/iroha-builder/ + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new + push: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo == github.event.pull_request.base.repo }} + tags: ${{ steps.meta_ghcr.outputs.tags }} + labels: ${{ steps.meta_ghcr.outputs.labels }} + # env: + # DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + # DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + - # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache + - name: Check if dockertaghash exists in remote registry + id: dockertag_already + run: | + echo "::set-output name=container::$DOCKERHUB_ORG/iroha-builder:$dockertag" + docker pull "$DOCKERHUB_ORG/iroha-builder:$dockertag" + - name: Possible ERROR, Dockerfile edited, image was build, but seems not pushed, CANNOT PULL. + if: failure() + #if: ${{ steps.docker_login.outcome != 'success' || steps.build_and_push.outcome != 'success' }} + env: + container: ${{steps.dockertag_already.outputs.container}} + dockertag: ${{env.dockertag}} + run: | + cat </dev/null <<'END' + ${{ toJson(needs) }} + END + - env: + container: ${{needs.Docker-iroha-builder.outputs.container}} + run: test -n "$container" + - name: System info + run: | + set -x + whoami + id $(whoami) + free || vm_stat | perl -ne '/page size of (\d+)/ and $size=$1; + /Pages\s+([^:]+)[^\d]+(\d+)/ and printf("%-16s % 16.2f Mi\n", "$1:", $2 * $size / 1048576);' + df -h + - name: Build info + run: | + cat << 'END' + ref:${{github.ref}} + sha:${{github.sha}} + run_number:${{github.run_number}} + event_name:${{github.event_name}} + event.action:${{github.event.action}} + event.issue.number:${{ github.event.issue.number }} + END + - name: export CC,BuildType from matrix.buildspec + run: | + echo >>$GITHUB_ENV OS=$(echo ${{matrix.buildspec}} | awk '{print $1}') + echo >>$GITHUB_ENV CC_NAME=$(echo ${{matrix.buildspec}} | awk '{print $2}') + echo >>$GITHUB_ENV BuildType=$(echo ${{matrix.buildspec}} | awk '{print $3}') + features=$(echo ${{matrix.buildspec}} | awk '{print $4}') + case $features in + normal) echo >>$GITHUB_ENV CMAKE_USE=""; features= ;; + ursa) echo >>$GITHUB_ENV CMAKE_USE="-DUSE_LIBURSA=ON";; + burrow) echo >>$GITHUB_ENV CMAKE_USE="-DUSE_BURROW=ON";; + *) echo "::error::Unknown features '$features'"; false ;; + esac + echo >>$GITHUB_ENV features="$features" + echo >>$GITHUB_ENV skip_testing=$(echo ${{matrix.buildspec}} | grep -Fo skip_testing) + - name: REF and SHA of commented PR to ENV + if: github.event.comment + run: > + curl -fsSL ${{github.event.issue.pull_request.url}} -H "Authorization: token ${{github.token}}" | jq -r ' + + "PR_REF="+.head.ref, + "PR_SHA="+.head.sha, + "PR_NUM="+(.number|tostring), + "PR_REPO="+.head.repo.full_name' >>$GITHUB_ENV + - name: Checkout head + uses: actions/checkout@v2 + with: + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} + fetch-depth: 0 ## full history + - name: export CC and CXX + env: + CCACHE_PATH: /usr/lib/ccache + run: | + set -xeu #o pipefail + if test $CC_NAME = llvm + then CC=/usr/local/opt/llvm/bin/clang + else CC=$CC_NAME + fi + echo >>$GITHUB_ENV CC=$CC + echo >>$GITHUB_ENV CXX=$(echo $CC | sed -es,gcc,g++, -es,clang,clang++,) + echo >>$GITHUB_PATH $CCACHE_PATH + ls -lA $CCACHE_PATH + $(realpath $CCACHE_PATH/gcc) --show-config + echo >>$GITHUB_ENV _CCACHE_DIR=$($(realpath $CCACHE_PATH/gcc) --show-config | sed -nE 's,.*cache_dir = ,,p') + echo >>$GITHUB_ENV NPROC=$(nproc | awk '{printf("%.0f",$1*0.77)}') + echo >>$GITHUB_ENV HOME=$HOME + - name: Restore cache CCache + uses: actions/cache@v2 + with: + path: ${{ env._CCACHE_DIR }} + key: ${{runner.os}}-ccache-${{ github.event.pull_request.head.sha }} + restore-keys: ${{runner.os}}-ccache- + - run: ccache --show-stats | tee /tmp/ccache-stats + - ## Read the docs https://vcpkg.readthedocs.io/en/latest/users/binarycaching/ https://github.com/microsoft/vcpkg/blob/master/docs/users/binarycaching.md + name: Restore cache Vcpkg binarycache ## NOTE not useng NuGet because on ubuntu nuget needs mono of 433MB, unusable. + uses: actions/cache@v2 + with: + path: | + ${{env.HOME}}/.cache/vcpkg/archives + key: ${{runner.os}}-vcpkg-${{env.CC_NAME}}.${{ hashFiles('vcpkg/**') }} + restore-keys: ${{runner.os}}-vcpkg-${{env.CC_NAME}}. + - name: Build iroha vcpkg dependancies + run: ./vcpkg/build_iroha_deps.sh $PWD/vcpkg-build; test -f $PWD/vcpkg-build/scripts/buildsystems/vcpkg.cmake + ## Takes 48m16s on default GitHub runner with 2 cores + ## Takes 13m41s on self-hosted AWS EC2 c5.x4large + # ________________________________________________________ + # Executed in 32,08 mins fish external + # usr time 110,52 mins 0,24 millis 110,52 mins + # sys time 12,26 mins 1,34 millis 12,26 mins + # + # All requested packages are currently installed. + # ________________________________________________________ + # Executed in 3,17 secs fish external + # usr time 2,05 secs 128,00 micros 2,05 secs + # sys time 0,70 secs 575,00 micros 0,70 secs + - name: CMake configure + ## Takes 13s on regular GitHub runner + run: cmake -B build -DCMAKE_TOOLCHAIN_FILE=$PWD/vcpkg-build/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=${{ env.BuildType }} -GNinja $CMAKE_USE -DTESTING=$( test "$skip_testing" = skip_testing && echo OFF || echo ON ) -DBENCHMARKING=$( test "$skip_testing" = skip_testing && echo OFF || echo ON ) -DPACKAGE_DEB=ON + #-DCMAKE_VERBOSE_MAKEFILE=ON ## Note: use for debug + - name: CMake build + run: | + set -x + ## reduce memory usage to do not overflow + cmake --build build --config ${{ env.BuildType }} -- -j$(nproc | awk '{printf("%.0f",$1*0.77)}') + echo ::notice::"$(./build/bin/irohad --version)" + ## Debug takes 18m44s on regular GitHub runner + ## Debug takes 7m41s on self-hosted AWS EC2 c5.x4large + ## Release takes 2m58s on self-hosted AWS EC2 c5.x4large + - name: CPack (linux only) + run: cd build; cpack; ## cmake --build build --target package + - run: ccache --show-stats | diff --side-by-side /tmp/ccache-stats - ||true + - name: Show free space and disk usage + if: ${{ always() }} + run: | + df -h || true + - name: Generate artifact suffix depending on matrix to env.ARTIFACT_SUFFIX + run: | + set -x + cc=$(echo $CC_NAME | sed -Ee's,[-/],,g' ) + build_type=$(echo $BuildType | tr A-Z a-z | sed -E -es,debug,dbg, -es,release,rel, ) + test $build_type = dbg -o $build_type = rel + uses=$(echo "$features" | tr ' ' - | tr A-Z a-z) + _os=${OS:+-$OS} _cc=${cc:+-$cc} _build_type=${build_type:+-$build_type} _uses=${uses:+-$uses} + echo >>$GITHUB_ENV ARTIFACT_SUFFIX=$_os$_cc$_build_type$_uses + echo >>$GITHUB_ENV _uses_suffix=$_uses + echo >>$GITHUB_ENV _compiler_suffix=$(test $cc != gcc9 && echo $_cc) + echo >>$GITHUB_ENV _debug_suffix=$(test "$build_type" = dbg && echo -debug || true) + - name: Upload artifact irohad + uses: actions/upload-artifact@v2 + with: + name: irohad${{env.ARTIFACT_SUFFIX}} + path: | + build/bin/irohad + build/bin/iroha-cli + - name: Upload artifact iroha-deb + uses: actions/upload-artifact@v2 + with: + name: iroha-deb${{env.ARTIFACT_SUFFIX}} + path: | + build/*.deb + - if: ${{ false }} ## Maybe test in another job + name: Upload artifact tests + uses: actions/upload-artifact@v2 + with: + name: iroha-tests-ubuntu${{env.ARTIFACT_SUFFIX}} + path: | + build/test_bin/** + build/test_data/** + - timeout-minutes: 40 + if: env.skip_testing == '' + name: CTest + run: | + echo ::group::'boilerplate' + set -euo pipefail + if test $(uname) = Darwin ;then + ## This is a common portable solution, but Debian and Ubuntu have their own wrappers + initdb --locale=C --encoding=UTF-8 --username=postgres $PWD/postgres_database + postgres -D $PWD/postgres_database -p5432 2>&1 >/tmp/postgres.log & { sleep .3; kill -0 $!; } ## use pg_ctl no need & + else ## Debian or Ubuntu + ## Need to go debian-specific way because + ## initdb is not allowed to be run as root, but we need to run as root + ## because GitHub actions runners have much issues with permissions. + mkdir postgres_database && chown iroha-ci postgres_database + echo /usr/lib/postgresql/12/bin/initdb --locale=C --encoding=UTF-8 --username=postgres $PWD/postgres_database | su iroha-ci + echo /usr/lib/postgresql/12/bin/pg_ctl start -D $PWD/postgres_database --log=$PWD/postgres_database/log | su iroha-ci + # ## Need to go debian-specific way because + # ## initdb is not allowed to be run as root, but we need to run as root + # ## because GitHub actions runners have much issues with permissions. + # cat </etc/postgresql/12/main/pg_hba.conf + # # TYPE DATABASE USER ADDRESS METHOD + # local all all trust + # host all all 127.0.0.1/32 trust + # host all all ::1/128 trust + # local replication all trust + # host replication all 127.0.0.1/32 trust + # host replication all ::1/128 trust + # END + # pg_ctlcluster 12 main start ## Cluster 'main' exist by default + # #OR pg_createcluster -p 5432 --start 12 iroha -- --locale=C --encoding=UTF-8 --username=postgres + fi + cd build + + ## This is just a small lifehack to TEMPORARY allow some tests to fail + cat ../.github/TESTS_ALLOWED_TO_FAIL | sort -u >ALLOW_TO_FAIL || true + + if test -e ALLOW_TO_FAIL + then echo "::warning:: There are TESTS_ALLOWED_TO_FAIL: "$(cat ALLOW_TO_FAIL) + fi + + grep_failed_tests(){ + grep 'The following tests FAILED:' -A10000 "$@" | tail +2 #| cut -d- -f2 | cut -d' ' -f2 | sort + } + exclude_allowed_to_fail(){ + grep -Fvf ALLOW_TO_FAIL "$@" + } + only_allowed_to_fail(){ + grep -Ff ALLOW_TO_FAIL "$@" + } + list_to_line(){ + comma='' + while read N d name sta ;do + echo -n "$comma$N-$name$sta" + comma=', ' + done + } + echo ::endgroup:: + + ## Run module_* tests in parallel and others subsequently + ## Cathgories sorted in order of importancy + CTEST_CATHEGORIES=( module tool framework regression system integration ) + ## Add rest available cathgories + CTEST_CATHEGORIES+=( $( + ctest --show-only=json-v1 -R "^(module|tool|framework|regression|system|integration)" | + jq -r .tests[].name | + cut -f1 -d_ | + sort -u | + grep -Fvf <( printf '%s\n' ${CTEST_CATHEGORIES[@]} ) + ) + ) || true + CTEST_DEFAULT_timeout=80 + CTEST_module_timeout=120 CTEST_module_parallel=4 + CTEST_tool_timeout=200 + CTEST_integration_timeout=120 + CTEST_integration_args='--repeat until-pass:10' ## FIXME remove this hack + CTEST_system_args='--repeat until-pass:10' ## FIXME remove this hack + + for cathegory in ${CTEST_CATHEGORIES[@]} ;do + echo >&2 ::group::"$cathegory tests" + set -x + timeout_name=CTEST_${cathegory}_timeout; timeout=${!timeout_name:-$CTEST_DEFAULT_timeout} + parallel_name=CTEST_${cathegory}_parallel; parallel=${!parallel_name:-} + args_name=CTEST_${cathegory}_args; args=${!args_name:-} + ctest -R "^${cathegory}_" ${parallel:+--parallel $parallel} --output-on-failure --no-tests=error --timeout $timeout ${args:-} \ + | tee ctest_$cathegory.out \ + || true + set +x + echo >&2 ::endgroup:: + done + + tests_passed=true + for t in ${CTEST_CATHEGORIES[@]} ;do + f=ctest_$t.out + if a=$(grep_failed_tests $f | exclude_allowed_to_fail | list_to_line) ;then + echo "::error::The following $(echo $t | tr a-z A-Z) tests FAILED but not in list ALLOW_TO_FAIL: $a" + tests_passed=false + fi + if o=$(grep_failed_tests $f | only_allowed_to_fail | list_to_line) ;then + echo "::warning::The following $t tests FAILED and ALLOWED TO FAIL: $o" + fi + done + $tests_passed From 72f8b16156ffef9d0c765d8b7b168ac94b4314cb Mon Sep 17 00:00:00 2001 From: safinsaf Date: Tue, 29 Mar 2022 14:32:26 +0300 Subject: [PATCH 066/130] Move to self-hosted runners Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 29e42425420..e2e8ec4e829 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -333,8 +333,8 @@ jobs: needs: - Docker-iroha-builder - generate_matrixes - #runs-on: [ self-hosted, Linux ] - runs-on: ubuntu-20.04 + runs-on: [ self-hosted, Linux ] + #runs-on: ubuntu-20.04 container: ## Container is taken from previous job image: &container_image ${{needs.Docker-iroha-builder.outputs.container}} options: --user root From 51939719093876336f6f09f97c3a8980cdf4a20c Mon Sep 17 00:00:00 2001 From: safinsaf Date: Tue, 29 Mar 2022 14:36:00 +0300 Subject: [PATCH 067/130] Move to self-hosted runners Signed-off-by: safinsaf --- .github/workflows/build-iroha1-fork.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index dc2a8be67c3..c000ce7ee26 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -366,8 +366,8 @@ jobs: needs: - Docker-iroha-builder - generate_matrixes - #runs-on: [ self-hosted, Linux ] - runs-on: ubuntu-20.04 + runs-on: [self-hosted, Linux] + #runs-on: ubuntu-20.04 container: ## Container is taken from previous job image: ${{needs.Docker-iroha-builder.outputs.container}} options: --user root From 079aafd6b1313edc19b34e372d4733f2f536b6ba Mon Sep 17 00:00:00 2001 From: safinsaf Date: Tue, 29 Mar 2022 16:36:28 +0300 Subject: [PATCH 068/130] Add deploy steps Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 228 ++++- .github/workflows/build-iroha1-fork.yml | 1079 ++++++++++++++++++++++- 2 files changed, 1304 insertions(+), 3 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index e2e8ec4e829..f370a7a80a4 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -199,7 +199,6 @@ jobs: id: docker_login uses: docker/login-action@v1 with: - #username: ${{ secrets.DOCKERHUB_USERNAME }} username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - &step_docker_login_ghcr @@ -375,7 +374,7 @@ jobs: echo >>$GITHUB_ENV features="$features" echo >>$GITHUB_ENV skip_testing=$(echo ${{matrix.buildspec}} | grep -Fo skip_testing) - *step_detect_commented_pr - - &step_checkout_full + - &step_checkout_full_head <<: *step_checkout_head with: <<: *step_checkout_with_head @@ -603,3 +602,228 @@ jobs: fi done $tests_passed + + ## Just because release is built 2..3 times faster make it a different job + build-UR: + <<: *job_ubuntu + strategy: &strategy_ubuntu_release + fail-fast: false + matrix: ${{ fromJSON( needs.generate_matrixes.outputs.matrix_ubuntu_release ) }} + if: &if_ubuntu_release ${{ fromJSON( needs.generate_matrixes.outputs.matrix_ubuntu_release ).include[0] }} + + ## Just to align picture + prepare-macos-env: + needs: check_workflow_yaml_coressponds_to_src_yaml + runs-on: macos-latest + steps: + - *step_show_context + + build-M: + needs: + - prepare-macos-env + - generate_matrixes + runs-on: macos-latest #[ self-hosted, MacOS ] # + strategy: + fail-fast: false + matrix: ${{ fromJSON( needs.generate_matrixes.outputs.matrix_macos ) }} + if: ${{ fromJSON( needs.generate_matrixes.outputs.matrix_macos ).include[0] }} + defaults: + run: + shell: bash + steps: + - *step_show_context + - *step_system_info + - *step_build_info + - *step_env_from_buildspec + - + name: Homebrew + run: brew install cmake ninja coreutils ccache bash + ## Takes 22 seconds with default github runner + - + if: ${{ contains(env.CC_NAME, 'gcc-10') }} + name: Homebrew GCC + run: brew install gcc@10 + - + if: ${{ contains(env.CC_NAME, 'llvm') }} + name: Homebrew LLVM + run: brew install llvm + - + if: ${{ contains(env.features, 'burrow') }} + name: Install protoc-gen-go for -DUSE_BURROW=ON + run: | + go get github.com/golang/protobuf/protoc-gen-go + echo >>$GITHUB_PATH $HOME/go/bin + - *step_detect_commented_pr + - *step_checkout_full_head + - <<: *step_export_cxx + env: + <<: *step_export_cxx_env + CCACHE_PATH: /usr/local/opt/ccache/libexec + - *step_restore_ccache + - *step_store_ccache_stats + - *step_vcpkg_cache + - *step_vcpkg_build + - *step_cmake_configure + - *step_cmake_build + - *step_compare_ccache_stats + - *step_always_after_build + - *step_artifact_suffix + - <<: *step_artifact_irohad + with: + name: irohad-macos${{env.ARTIFACT_SUFFIX}} + path: *step_artifact_irohad_path + - *step_artifact_tests + - &step_brew_postgres + name: Install Postgres on MacOS + run: brew install postgresql + - <<: *step_ctest + timeout-minutes: 70 + + ## Just to align picture + prepare-windows-env: + needs: check_workflow_yaml_coressponds_to_src_yaml + runs-on: windows-latest + steps: + - *step_show_context + defaults: + run: + shell: bash + + build-W: + needs: + - prepare-windows-env + - generate_matrixes + runs-on: windows-latest + strategy: + fail-fast: false + matrix: ${{ fromJSON( needs.generate_matrixes.outputs.matrix_windows ) }} + if: ${{ false && ( fromJSON( needs.generate_matrixes.outputs.matrix_windows ).include[0] ) }} + defaults: + run: + shell: bash #pwsh + working-directory: &workdir 'C:\github\iroha' ## Use disk C: because D: is out of space + steps: + - name: Create working-directory, export WORKDIR + run: | + set -x + mkdir -p "$WORKDIR" + echo $PWD + echo >>$GITHUB_ENV WORKDIR="$WORKDIR" + working-directory: 'C:\' + env: { WORKDIR: *workdir } + - name: uname in bash + run: uname + shell: bash + - name: uname in [default] pwsh shell + run: uname + shell: pwsh + - &step_choco_install + name: Chocolatey install + run: choco install cmake ninja #ccache + - *step_checkout_full_head + - name: move to workdir + run: | + set -x + echo $PWD + shopt -s dotglob nullglob + mv -vf * -t "$WORKDIR" + working-directory: + #- *step_restore_ccache + #- *step_vcpkg_cache + - *step_vcpkg_build + - *step_cmake_configure + - *step_cmake_build + - *step_always_after_build + - name: Install Postgres on Windows + run: choco install postgresql + # - *step_ctest + + ## Build and publish docker image named 'hyperledger/iroha' with irohad and iroha tools inside. + ## The result docker image is pushed with tags :branch_name, :pr-NUMBER, :tag_name, + ## and :latest (for git-tags). + ## Those docker image tags could be extended with suffixes with compiler and build type like + ## -gcc10, -clang, -debug, -gcc10-debug. Like :latest-debug, :main-debug, :1.3.0-gcc10-debug. + ## Result image name could look like: hyperledger/iroha:pr-1117, hyperledger/iroha:nightly. + ## Note: image is push only when DockerHub login-token pair available - not to PRs from forks + docker-R: &job_docker_image_release + needs: + - build-UR + - generate_matrixes + runs-on: [ self-hosted, Linux ] #ubuntu-latest + # strategy: *strategy_ubuntu_release + # if: *if_ubuntu_release + strategy: + fail-fast: false + matrix: ${{ fromJSON( needs.generate_matrixes.outputs.matrix_dockerimage_release ) }} + if: ${{ fromJSON( needs.generate_matrixes.outputs.matrix_dockerimage_release ).include[0] }} + #env: &env_dockerhub_release + # <<: *env_dockerhub + # IMAGE_NAME: iroha + env: + IMAGE_NAME: iroha + steps: + - *step_show_context + - *step_system_info + - *step_build_info + - *step_env_from_buildspec + - *step_detect_commented_pr + - *step_checkout_head + - *step_artifact_suffix + - name: Download artifact + uses: actions/download-artifact@v2 + with: + name: iroha-deb${{env.ARTIFACT_SUFFIX}} + - name: Rename artifact debs + run: | + mv *iroha_shepherd.deb docker/release/iroha_shepherd.deb + mv *irohad.deb docker/release/iroha.deb + - <<: *step_docker_tag + env: + dockertag: ${{ hashFiles('docker/release/**') }} + - <<: *step_docker_meta + with: &step_docker_release_meta_with + images: | + ${{ env.DOCKERHUB_ORG }}/${{ env.IMAGE_NAME }}${{ env._uses_suffix }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=ref,event=tag + type=schedule + flavor: | + suffix=${{env._compiler_suffix}}${{env._debug_suffix}},onlatest=true + #maybetodo flavor: prefix=${{ env.USES_PREFIX }} ## In case creating repository hyperledger/iroha-burrow denied, Use tag prefix hyperledger/iroha:burrow-xxxx + - <<: *step_docker_meta_ghcr + with: + <<: *step_docker_release_meta_with + images: ghcr.io/${{ github.repository }}${{ env._uses_suffix }} + - *step_docker_login + - *step_docker_login_ghcr + - *step_warn_docker_no_push + - *step_docker_buildx + - <<: *step_docker_cache + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-release-${{env.dockertag}} + restore-keys: ${{ runner.os }}-buildx-release + - <<: *step_docker_build_and_push + with: + <<: *step_docker_build_and_push_with + context: docker/release/ + push: ${{ steps.docker_login.outcome == 'success' }} + - <<: *step_docker_build_and_push_ghcr + with: + <<: *step_docker_build_and_push_ghcr-with + context: docker/release/ + - *step_docker_move_cache + + docker-D: + <<: *job_docker_image_release + needs: + - build-UD + - generate_matrixes + # strategy: *strategy_ubuntu_debug + # if: *if_ubuntu_debug + strategy: + fail-fast: false + matrix: ${{ fromJSON( needs.generate_matrixes.outputs.matrix_dockerimage_debug ) }} + if: ${{ fromJSON( needs.generate_matrixes.outputs.matrix_dockerimage_debug ).include[0] }} \ No newline at end of file diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index c000ce7ee26..c8e17006f02 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -231,7 +231,6 @@ jobs: id: docker_login uses: docker/login-action@v1 with: - #username: ${{ secrets.DOCKERHUB_USERNAME }} username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Log in to the Container registry GHCR @@ -648,3 +647,1081 @@ jobs: fi done $tests_passed + ## Just because release is built 2..3 times faster make it a different job + build-UR: + needs: + - Docker-iroha-builder + - generate_matrixes + runs-on: [self-hosted, Linux] + #runs-on: ubuntu-20.04 + container: ## Container is taken from previous job + image: ${{needs.Docker-iroha-builder.outputs.container}} + options: --user root + defaults: + run: + shell: bash + steps: + - name: Show context + run: | + echo "::group::GitHub context" + cat <<'END' + ${{ toJson(github) }} + END + echo "::endgroup::" + echo "::group::GitHub needs" + cat <<'END' + ${{ toJson(needs) }} + END + echo "::endgroup::" + - name: Show needs + run: | + cat >/dev/null <<'END' + ${{ toJson(needs) }} + END + - env: + container: ${{needs.Docker-iroha-builder.outputs.container}} + run: test -n "$container" + - name: System info + run: | + set -x + whoami + id $(whoami) + free || vm_stat | perl -ne '/page size of (\d+)/ and $size=$1; + /Pages\s+([^:]+)[^\d]+(\d+)/ and printf("%-16s % 16.2f Mi\n", "$1:", $2 * $size / 1048576);' + df -h + - name: Build info + run: | + cat << 'END' + ref:${{github.ref}} + sha:${{github.sha}} + run_number:${{github.run_number}} + event_name:${{github.event_name}} + event.action:${{github.event.action}} + event.issue.number:${{ github.event.issue.number }} + END + - name: export CC,BuildType from matrix.buildspec + run: | + echo >>$GITHUB_ENV OS=$(echo ${{matrix.buildspec}} | awk '{print $1}') + echo >>$GITHUB_ENV CC_NAME=$(echo ${{matrix.buildspec}} | awk '{print $2}') + echo >>$GITHUB_ENV BuildType=$(echo ${{matrix.buildspec}} | awk '{print $3}') + features=$(echo ${{matrix.buildspec}} | awk '{print $4}') + case $features in + normal) echo >>$GITHUB_ENV CMAKE_USE=""; features= ;; + ursa) echo >>$GITHUB_ENV CMAKE_USE="-DUSE_LIBURSA=ON";; + burrow) echo >>$GITHUB_ENV CMAKE_USE="-DUSE_BURROW=ON";; + *) echo "::error::Unknown features '$features'"; false ;; + esac + echo >>$GITHUB_ENV features="$features" + echo >>$GITHUB_ENV skip_testing=$(echo ${{matrix.buildspec}} | grep -Fo skip_testing) + - name: REF and SHA of commented PR to ENV + if: github.event.comment + run: > + curl -fsSL ${{github.event.issue.pull_request.url}} -H "Authorization: token ${{github.token}}" | jq -r ' + + "PR_REF="+.head.ref, + "PR_SHA="+.head.sha, + "PR_NUM="+(.number|tostring), + "PR_REPO="+.head.repo.full_name' >>$GITHUB_ENV + - name: Checkout head + uses: actions/checkout@v2 + with: + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} + fetch-depth: 0 ## full history + - name: export CC and CXX + env: + CCACHE_PATH: /usr/lib/ccache + run: | + set -xeu #o pipefail + if test $CC_NAME = llvm + then CC=/usr/local/opt/llvm/bin/clang + else CC=$CC_NAME + fi + echo >>$GITHUB_ENV CC=$CC + echo >>$GITHUB_ENV CXX=$(echo $CC | sed -es,gcc,g++, -es,clang,clang++,) + echo >>$GITHUB_PATH $CCACHE_PATH + ls -lA $CCACHE_PATH + $(realpath $CCACHE_PATH/gcc) --show-config + echo >>$GITHUB_ENV _CCACHE_DIR=$($(realpath $CCACHE_PATH/gcc) --show-config | sed -nE 's,.*cache_dir = ,,p') + echo >>$GITHUB_ENV NPROC=$(nproc | awk '{printf("%.0f",$1*0.77)}') + echo >>$GITHUB_ENV HOME=$HOME + - name: Restore cache CCache + uses: actions/cache@v2 + with: + path: ${{ env._CCACHE_DIR }} + key: ${{runner.os}}-ccache-${{ github.event.pull_request.head.sha }} + restore-keys: ${{runner.os}}-ccache- + - run: ccache --show-stats | tee /tmp/ccache-stats + - ## Read the docs https://vcpkg.readthedocs.io/en/latest/users/binarycaching/ https://github.com/microsoft/vcpkg/blob/master/docs/users/binarycaching.md + name: Restore cache Vcpkg binarycache ## NOTE not useng NuGet because on ubuntu nuget needs mono of 433MB, unusable. + uses: actions/cache@v2 + with: + path: | + ${{env.HOME}}/.cache/vcpkg/archives + key: ${{runner.os}}-vcpkg-${{env.CC_NAME}}.${{ hashFiles('vcpkg/**') }} + restore-keys: ${{runner.os}}-vcpkg-${{env.CC_NAME}}. + - name: Build iroha vcpkg dependancies + run: ./vcpkg/build_iroha_deps.sh $PWD/vcpkg-build; test -f $PWD/vcpkg-build/scripts/buildsystems/vcpkg.cmake + ## Takes 48m16s on default GitHub runner with 2 cores + ## Takes 13m41s on self-hosted AWS EC2 c5.x4large + # ________________________________________________________ + # Executed in 32,08 mins fish external + # usr time 110,52 mins 0,24 millis 110,52 mins + # sys time 12,26 mins 1,34 millis 12,26 mins + # + # All requested packages are currently installed. + # ________________________________________________________ + # Executed in 3,17 secs fish external + # usr time 2,05 secs 128,00 micros 2,05 secs + # sys time 0,70 secs 575,00 micros 0,70 secs + - name: CMake configure + ## Takes 13s on regular GitHub runner + run: cmake -B build -DCMAKE_TOOLCHAIN_FILE=$PWD/vcpkg-build/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=${{ env.BuildType }} -GNinja $CMAKE_USE -DTESTING=$( test "$skip_testing" = skip_testing && echo OFF || echo ON ) -DBENCHMARKING=$( test "$skip_testing" = skip_testing && echo OFF || echo ON ) -DPACKAGE_DEB=ON + #-DCMAKE_VERBOSE_MAKEFILE=ON ## Note: use for debug + - name: CMake build + run: | + set -x + ## reduce memory usage to do not overflow + cmake --build build --config ${{ env.BuildType }} -- -j$(nproc | awk '{printf("%.0f",$1*0.77)}') + echo ::notice::"$(./build/bin/irohad --version)" + ## Debug takes 18m44s on regular GitHub runner + ## Debug takes 7m41s on self-hosted AWS EC2 c5.x4large + ## Release takes 2m58s on self-hosted AWS EC2 c5.x4large + - name: CPack (linux only) + run: cd build; cpack; ## cmake --build build --target package + - run: ccache --show-stats | diff --side-by-side /tmp/ccache-stats - ||true + - name: Show free space and disk usage + if: ${{ always() }} + run: | + df -h || true + - name: Generate artifact suffix depending on matrix to env.ARTIFACT_SUFFIX + run: | + set -x + cc=$(echo $CC_NAME | sed -Ee's,[-/],,g' ) + build_type=$(echo $BuildType | tr A-Z a-z | sed -E -es,debug,dbg, -es,release,rel, ) + test $build_type = dbg -o $build_type = rel + uses=$(echo "$features" | tr ' ' - | tr A-Z a-z) + _os=${OS:+-$OS} _cc=${cc:+-$cc} _build_type=${build_type:+-$build_type} _uses=${uses:+-$uses} + echo >>$GITHUB_ENV ARTIFACT_SUFFIX=$_os$_cc$_build_type$_uses + echo >>$GITHUB_ENV _uses_suffix=$_uses + echo >>$GITHUB_ENV _compiler_suffix=$(test $cc != gcc9 && echo $_cc) + echo >>$GITHUB_ENV _debug_suffix=$(test "$build_type" = dbg && echo -debug || true) + - name: Upload artifact irohad + uses: actions/upload-artifact@v2 + with: + name: irohad${{env.ARTIFACT_SUFFIX}} + path: | + build/bin/irohad + build/bin/iroha-cli + - name: Upload artifact iroha-deb + uses: actions/upload-artifact@v2 + with: + name: iroha-deb${{env.ARTIFACT_SUFFIX}} + path: | + build/*.deb + - if: ${{ false }} ## Maybe test in another job + name: Upload artifact tests + uses: actions/upload-artifact@v2 + with: + name: iroha-tests-ubuntu${{env.ARTIFACT_SUFFIX}} + path: | + build/test_bin/** + build/test_data/** + - timeout-minutes: 40 + if: env.skip_testing == '' + name: CTest + run: | + echo ::group::'boilerplate' + set -euo pipefail + if test $(uname) = Darwin ;then + ## This is a common portable solution, but Debian and Ubuntu have their own wrappers + initdb --locale=C --encoding=UTF-8 --username=postgres $PWD/postgres_database + postgres -D $PWD/postgres_database -p5432 2>&1 >/tmp/postgres.log & { sleep .3; kill -0 $!; } ## use pg_ctl no need & + else ## Debian or Ubuntu + ## Need to go debian-specific way because + ## initdb is not allowed to be run as root, but we need to run as root + ## because GitHub actions runners have much issues with permissions. + mkdir postgres_database && chown iroha-ci postgres_database + echo /usr/lib/postgresql/12/bin/initdb --locale=C --encoding=UTF-8 --username=postgres $PWD/postgres_database | su iroha-ci + echo /usr/lib/postgresql/12/bin/pg_ctl start -D $PWD/postgres_database --log=$PWD/postgres_database/log | su iroha-ci + # ## Need to go debian-specific way because + # ## initdb is not allowed to be run as root, but we need to run as root + # ## because GitHub actions runners have much issues with permissions. + # cat </etc/postgresql/12/main/pg_hba.conf + # # TYPE DATABASE USER ADDRESS METHOD + # local all all trust + # host all all 127.0.0.1/32 trust + # host all all ::1/128 trust + # local replication all trust + # host replication all 127.0.0.1/32 trust + # host replication all ::1/128 trust + # END + # pg_ctlcluster 12 main start ## Cluster 'main' exist by default + # #OR pg_createcluster -p 5432 --start 12 iroha -- --locale=C --encoding=UTF-8 --username=postgres + fi + cd build + + ## This is just a small lifehack to TEMPORARY allow some tests to fail + cat ../.github/TESTS_ALLOWED_TO_FAIL | sort -u >ALLOW_TO_FAIL || true + + if test -e ALLOW_TO_FAIL + then echo "::warning:: There are TESTS_ALLOWED_TO_FAIL: "$(cat ALLOW_TO_FAIL) + fi + + grep_failed_tests(){ + grep 'The following tests FAILED:' -A10000 "$@" | tail +2 #| cut -d- -f2 | cut -d' ' -f2 | sort + } + exclude_allowed_to_fail(){ + grep -Fvf ALLOW_TO_FAIL "$@" + } + only_allowed_to_fail(){ + grep -Ff ALLOW_TO_FAIL "$@" + } + list_to_line(){ + comma='' + while read N d name sta ;do + echo -n "$comma$N-$name$sta" + comma=', ' + done + } + echo ::endgroup:: + + ## Run module_* tests in parallel and others subsequently + ## Cathgories sorted in order of importancy + CTEST_CATHEGORIES=( module tool framework regression system integration ) + ## Add rest available cathgories + CTEST_CATHEGORIES+=( $( + ctest --show-only=json-v1 -R "^(module|tool|framework|regression|system|integration)" | + jq -r .tests[].name | + cut -f1 -d_ | + sort -u | + grep -Fvf <( printf '%s\n' ${CTEST_CATHEGORIES[@]} ) + ) + ) || true + CTEST_DEFAULT_timeout=80 + CTEST_module_timeout=120 CTEST_module_parallel=4 + CTEST_tool_timeout=200 + CTEST_integration_timeout=120 + CTEST_integration_args='--repeat until-pass:10' ## FIXME remove this hack + CTEST_system_args='--repeat until-pass:10' ## FIXME remove this hack + + for cathegory in ${CTEST_CATHEGORIES[@]} ;do + echo >&2 ::group::"$cathegory tests" + set -x + timeout_name=CTEST_${cathegory}_timeout; timeout=${!timeout_name:-$CTEST_DEFAULT_timeout} + parallel_name=CTEST_${cathegory}_parallel; parallel=${!parallel_name:-} + args_name=CTEST_${cathegory}_args; args=${!args_name:-} + ctest -R "^${cathegory}_" ${parallel:+--parallel $parallel} --output-on-failure --no-tests=error --timeout $timeout ${args:-} \ + | tee ctest_$cathegory.out \ + || true + set +x + echo >&2 ::endgroup:: + done + + tests_passed=true + for t in ${CTEST_CATHEGORIES[@]} ;do + f=ctest_$t.out + if a=$(grep_failed_tests $f | exclude_allowed_to_fail | list_to_line) ;then + echo "::error::The following $(echo $t | tr a-z A-Z) tests FAILED but not in list ALLOW_TO_FAIL: $a" + tests_passed=false + fi + if o=$(grep_failed_tests $f | only_allowed_to_fail | list_to_line) ;then + echo "::warning::The following $t tests FAILED and ALLOWED TO FAIL: $o" + fi + done + $tests_passed + strategy: + fail-fast: false + matrix: ${{ fromJSON( needs.generate_matrixes.outputs.matrix_ubuntu_release ) }} + if: ${{ fromJSON( needs.generate_matrixes.outputs.matrix_ubuntu_release ).include[0] }} + ## Just to align picture + prepare-macos-env: + needs: check_workflow_yaml_coressponds_to_src_yaml + runs-on: macos-latest + steps: + - name: Show context + run: | + echo "::group::GitHub context" + cat <<'END' + ${{ toJson(github) }} + END + echo "::endgroup::" + echo "::group::GitHub needs" + cat <<'END' + ${{ toJson(needs) }} + END + echo "::endgroup::" + build-M: + needs: + - prepare-macos-env + - generate_matrixes + runs-on: macos-latest #[ self-hosted, MacOS ] # + strategy: + fail-fast: false + matrix: ${{ fromJSON( needs.generate_matrixes.outputs.matrix_macos ) }} + if: ${{ fromJSON( needs.generate_matrixes.outputs.matrix_macos ).include[0] }} + defaults: + run: + shell: bash + steps: + - name: Show context + run: | + echo "::group::GitHub context" + cat <<'END' + ${{ toJson(github) }} + END + echo "::endgroup::" + echo "::group::GitHub needs" + cat <<'END' + ${{ toJson(needs) }} + END + echo "::endgroup::" + - name: System info + run: | + set -x + whoami + id $(whoami) + free || vm_stat | perl -ne '/page size of (\d+)/ and $size=$1; + /Pages\s+([^:]+)[^\d]+(\d+)/ and printf("%-16s % 16.2f Mi\n", "$1:", $2 * $size / 1048576);' + df -h + - name: Build info + run: | + cat << 'END' + ref:${{github.ref}} + sha:${{github.sha}} + run_number:${{github.run_number}} + event_name:${{github.event_name}} + event.action:${{github.event.action}} + event.issue.number:${{ github.event.issue.number }} + END + - name: export CC,BuildType from matrix.buildspec + run: | + echo >>$GITHUB_ENV OS=$(echo ${{matrix.buildspec}} | awk '{print $1}') + echo >>$GITHUB_ENV CC_NAME=$(echo ${{matrix.buildspec}} | awk '{print $2}') + echo >>$GITHUB_ENV BuildType=$(echo ${{matrix.buildspec}} | awk '{print $3}') + features=$(echo ${{matrix.buildspec}} | awk '{print $4}') + case $features in + normal) echo >>$GITHUB_ENV CMAKE_USE=""; features= ;; + ursa) echo >>$GITHUB_ENV CMAKE_USE="-DUSE_LIBURSA=ON";; + burrow) echo >>$GITHUB_ENV CMAKE_USE="-DUSE_BURROW=ON";; + *) echo "::error::Unknown features '$features'"; false ;; + esac + echo >>$GITHUB_ENV features="$features" + echo >>$GITHUB_ENV skip_testing=$(echo ${{matrix.buildspec}} | grep -Fo skip_testing) + - name: Homebrew + run: brew install cmake ninja coreutils ccache bash + ## Takes 22 seconds with default github runner + - if: ${{ contains(env.CC_NAME, 'gcc-10') }} + name: Homebrew GCC + run: brew install gcc@10 + - if: ${{ contains(env.CC_NAME, 'llvm') }} + name: Homebrew LLVM + run: brew install llvm + - if: ${{ contains(env.features, 'burrow') }} + name: Install protoc-gen-go for -DUSE_BURROW=ON + run: | + go get github.com/golang/protobuf/protoc-gen-go + echo >>$GITHUB_PATH $HOME/go/bin + - name: REF and SHA of commented PR to ENV + if: github.event.comment + run: > + curl -fsSL ${{github.event.issue.pull_request.url}} -H "Authorization: token ${{github.token}}" | jq -r ' + + "PR_REF="+.head.ref, + "PR_SHA="+.head.sha, + "PR_NUM="+(.number|tostring), + "PR_REPO="+.head.repo.full_name' >>$GITHUB_ENV + - name: Checkout head + uses: actions/checkout@v2 + with: + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} + fetch-depth: 0 ## full history + - name: export CC and CXX + run: | + set -xeu #o pipefail + if test $CC_NAME = llvm + then CC=/usr/local/opt/llvm/bin/clang + else CC=$CC_NAME + fi + echo >>$GITHUB_ENV CC=$CC + echo >>$GITHUB_ENV CXX=$(echo $CC | sed -es,gcc,g++, -es,clang,clang++,) + echo >>$GITHUB_PATH $CCACHE_PATH + ls -lA $CCACHE_PATH + $(realpath $CCACHE_PATH/gcc) --show-config + echo >>$GITHUB_ENV _CCACHE_DIR=$($(realpath $CCACHE_PATH/gcc) --show-config | sed -nE 's,.*cache_dir = ,,p') + echo >>$GITHUB_ENV NPROC=$(nproc | awk '{printf("%.0f",$1*0.77)}') + echo >>$GITHUB_ENV HOME=$HOME + env: + CCACHE_PATH: /usr/local/opt/ccache/libexec + - name: Restore cache CCache + uses: actions/cache@v2 + with: + path: ${{ env._CCACHE_DIR }} + key: ${{runner.os}}-ccache-${{ github.event.pull_request.head.sha }} + restore-keys: ${{runner.os}}-ccache- + - run: ccache --show-stats | tee /tmp/ccache-stats + - ## Read the docs https://vcpkg.readthedocs.io/en/latest/users/binarycaching/ https://github.com/microsoft/vcpkg/blob/master/docs/users/binarycaching.md + name: Restore cache Vcpkg binarycache ## NOTE not useng NuGet because on ubuntu nuget needs mono of 433MB, unusable. + uses: actions/cache@v2 + with: + path: | + ${{env.HOME}}/.cache/vcpkg/archives + key: ${{runner.os}}-vcpkg-${{env.CC_NAME}}.${{ hashFiles('vcpkg/**') }} + restore-keys: ${{runner.os}}-vcpkg-${{env.CC_NAME}}. + - name: Build iroha vcpkg dependancies + run: ./vcpkg/build_iroha_deps.sh $PWD/vcpkg-build; test -f $PWD/vcpkg-build/scripts/buildsystems/vcpkg.cmake + ## Takes 48m16s on default GitHub runner with 2 cores + ## Takes 13m41s on self-hosted AWS EC2 c5.x4large + # ________________________________________________________ + # Executed in 32,08 mins fish external + # usr time 110,52 mins 0,24 millis 110,52 mins + # sys time 12,26 mins 1,34 millis 12,26 mins + # + # All requested packages are currently installed. + # ________________________________________________________ + # Executed in 3,17 secs fish external + # usr time 2,05 secs 128,00 micros 2,05 secs + # sys time 0,70 secs 575,00 micros 0,70 secs + - name: CMake configure + ## Takes 13s on regular GitHub runner + run: cmake -B build -DCMAKE_TOOLCHAIN_FILE=$PWD/vcpkg-build/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=${{ env.BuildType }} -GNinja $CMAKE_USE -DTESTING=$( test "$skip_testing" = skip_testing && echo OFF || echo ON ) -DBENCHMARKING=$( test "$skip_testing" = skip_testing && echo OFF || echo ON ) -DPACKAGE_DEB=ON + #-DCMAKE_VERBOSE_MAKEFILE=ON ## Note: use for debug + - name: CMake build + run: | + set -x + ## reduce memory usage to do not overflow + cmake --build build --config ${{ env.BuildType }} -- -j$(nproc | awk '{printf("%.0f",$1*0.77)}') + echo ::notice::"$(./build/bin/irohad --version)" + ## Debug takes 18m44s on regular GitHub runner + ## Debug takes 7m41s on self-hosted AWS EC2 c5.x4large + ## Release takes 2m58s on self-hosted AWS EC2 c5.x4large + - run: ccache --show-stats | diff --side-by-side /tmp/ccache-stats - ||true + - name: Show free space and disk usage + if: ${{ always() }} + run: | + df -h || true + - name: Generate artifact suffix depending on matrix to env.ARTIFACT_SUFFIX + run: | + set -x + cc=$(echo $CC_NAME | sed -Ee's,[-/],,g' ) + build_type=$(echo $BuildType | tr A-Z a-z | sed -E -es,debug,dbg, -es,release,rel, ) + test $build_type = dbg -o $build_type = rel + uses=$(echo "$features" | tr ' ' - | tr A-Z a-z) + _os=${OS:+-$OS} _cc=${cc:+-$cc} _build_type=${build_type:+-$build_type} _uses=${uses:+-$uses} + echo >>$GITHUB_ENV ARTIFACT_SUFFIX=$_os$_cc$_build_type$_uses + echo >>$GITHUB_ENV _uses_suffix=$_uses + echo >>$GITHUB_ENV _compiler_suffix=$(test $cc != gcc9 && echo $_cc) + echo >>$GITHUB_ENV _debug_suffix=$(test "$build_type" = dbg && echo -debug || true) + - name: Upload artifact irohad + uses: actions/upload-artifact@v2 + with: + name: irohad-macos${{env.ARTIFACT_SUFFIX}} + path: | + build/bin/irohad + build/bin/iroha-cli + - if: ${{ false }} ## Maybe test in another job + name: Upload artifact tests + uses: actions/upload-artifact@v2 + with: + name: iroha-tests-ubuntu${{env.ARTIFACT_SUFFIX}} + path: | + build/test_bin/** + build/test_data/** + - name: Install Postgres on MacOS + run: brew install postgresql + - if: env.skip_testing == '' + name: CTest + run: | + echo ::group::'boilerplate' + set -euo pipefail + if test $(uname) = Darwin ;then + ## This is a common portable solution, but Debian and Ubuntu have their own wrappers + initdb --locale=C --encoding=UTF-8 --username=postgres $PWD/postgres_database + postgres -D $PWD/postgres_database -p5432 2>&1 >/tmp/postgres.log & { sleep .3; kill -0 $!; } ## use pg_ctl no need & + else ## Debian or Ubuntu + ## Need to go debian-specific way because + ## initdb is not allowed to be run as root, but we need to run as root + ## because GitHub actions runners have much issues with permissions. + mkdir postgres_database && chown iroha-ci postgres_database + echo /usr/lib/postgresql/12/bin/initdb --locale=C --encoding=UTF-8 --username=postgres $PWD/postgres_database | su iroha-ci + echo /usr/lib/postgresql/12/bin/pg_ctl start -D $PWD/postgres_database --log=$PWD/postgres_database/log | su iroha-ci + # ## Need to go debian-specific way because + # ## initdb is not allowed to be run as root, but we need to run as root + # ## because GitHub actions runners have much issues with permissions. + # cat </etc/postgresql/12/main/pg_hba.conf + # # TYPE DATABASE USER ADDRESS METHOD + # local all all trust + # host all all 127.0.0.1/32 trust + # host all all ::1/128 trust + # local replication all trust + # host replication all 127.0.0.1/32 trust + # host replication all ::1/128 trust + # END + # pg_ctlcluster 12 main start ## Cluster 'main' exist by default + # #OR pg_createcluster -p 5432 --start 12 iroha -- --locale=C --encoding=UTF-8 --username=postgres + fi + cd build + + ## This is just a small lifehack to TEMPORARY allow some tests to fail + cat ../.github/TESTS_ALLOWED_TO_FAIL | sort -u >ALLOW_TO_FAIL || true + + if test -e ALLOW_TO_FAIL + then echo "::warning:: There are TESTS_ALLOWED_TO_FAIL: "$(cat ALLOW_TO_FAIL) + fi + + grep_failed_tests(){ + grep 'The following tests FAILED:' -A10000 "$@" | tail +2 #| cut -d- -f2 | cut -d' ' -f2 | sort + } + exclude_allowed_to_fail(){ + grep -Fvf ALLOW_TO_FAIL "$@" + } + only_allowed_to_fail(){ + grep -Ff ALLOW_TO_FAIL "$@" + } + list_to_line(){ + comma='' + while read N d name sta ;do + echo -n "$comma$N-$name$sta" + comma=', ' + done + } + echo ::endgroup:: + + ## Run module_* tests in parallel and others subsequently + ## Cathgories sorted in order of importancy + CTEST_CATHEGORIES=( module tool framework regression system integration ) + ## Add rest available cathgories + CTEST_CATHEGORIES+=( $( + ctest --show-only=json-v1 -R "^(module|tool|framework|regression|system|integration)" | + jq -r .tests[].name | + cut -f1 -d_ | + sort -u | + grep -Fvf <( printf '%s\n' ${CTEST_CATHEGORIES[@]} ) + ) + ) || true + CTEST_DEFAULT_timeout=80 + CTEST_module_timeout=120 CTEST_module_parallel=4 + CTEST_tool_timeout=200 + CTEST_integration_timeout=120 + CTEST_integration_args='--repeat until-pass:10' ## FIXME remove this hack + CTEST_system_args='--repeat until-pass:10' ## FIXME remove this hack + + for cathegory in ${CTEST_CATHEGORIES[@]} ;do + echo >&2 ::group::"$cathegory tests" + set -x + timeout_name=CTEST_${cathegory}_timeout; timeout=${!timeout_name:-$CTEST_DEFAULT_timeout} + parallel_name=CTEST_${cathegory}_parallel; parallel=${!parallel_name:-} + args_name=CTEST_${cathegory}_args; args=${!args_name:-} + ctest -R "^${cathegory}_" ${parallel:+--parallel $parallel} --output-on-failure --no-tests=error --timeout $timeout ${args:-} \ + | tee ctest_$cathegory.out \ + || true + set +x + echo >&2 ::endgroup:: + done + + tests_passed=true + for t in ${CTEST_CATHEGORIES[@]} ;do + f=ctest_$t.out + if a=$(grep_failed_tests $f | exclude_allowed_to_fail | list_to_line) ;then + echo "::error::The following $(echo $t | tr a-z A-Z) tests FAILED but not in list ALLOW_TO_FAIL: $a" + tests_passed=false + fi + if o=$(grep_failed_tests $f | only_allowed_to_fail | list_to_line) ;then + echo "::warning::The following $t tests FAILED and ALLOWED TO FAIL: $o" + fi + done + $tests_passed + timeout-minutes: 70 + ## Just to align picture + prepare-windows-env: + needs: check_workflow_yaml_coressponds_to_src_yaml + runs-on: windows-latest + steps: + - name: Show context + run: | + echo "::group::GitHub context" + cat <<'END' + ${{ toJson(github) }} + END + echo "::endgroup::" + echo "::group::GitHub needs" + cat <<'END' + ${{ toJson(needs) }} + END + echo "::endgroup::" + defaults: + run: + shell: bash + build-W: + needs: + - prepare-windows-env + - generate_matrixes + runs-on: windows-latest + strategy: + fail-fast: false + matrix: ${{ fromJSON( needs.generate_matrixes.outputs.matrix_windows ) }} + if: ${{ false && ( fromJSON( needs.generate_matrixes.outputs.matrix_windows ).include[0] ) }} + defaults: + run: + shell: bash #pwsh + working-directory: 'C:\github\iroha' ## Use disk C: because D: is out of space + steps: + - name: Create working-directory, export WORKDIR + run: | + set -x + mkdir -p "$WORKDIR" + echo $PWD + echo >>$GITHUB_ENV WORKDIR="$WORKDIR" + working-directory: 'C:\' + env: {WORKDIR: 'C:\github\iroha'} + - name: uname in bash + run: uname + shell: bash + - name: uname in [default] pwsh shell + run: uname + shell: pwsh + - name: Chocolatey install + run: choco install cmake ninja #ccache + - name: Checkout head + uses: actions/checkout@v2 + with: + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} + fetch-depth: 0 ## full history + - name: move to workdir + run: | + set -x + echo $PWD + shopt -s dotglob nullglob + mv -vf * -t "$WORKDIR" + working-directory: + #- *step_restore_ccache + #- *step_vcpkg_cache + - name: Build iroha vcpkg dependancies + run: ./vcpkg/build_iroha_deps.sh $PWD/vcpkg-build; test -f $PWD/vcpkg-build/scripts/buildsystems/vcpkg.cmake + ## Takes 48m16s on default GitHub runner with 2 cores + ## Takes 13m41s on self-hosted AWS EC2 c5.x4large + # ________________________________________________________ + # Executed in 32,08 mins fish external + # usr time 110,52 mins 0,24 millis 110,52 mins + # sys time 12,26 mins 1,34 millis 12,26 mins + # + # All requested packages are currently installed. + # ________________________________________________________ + # Executed in 3,17 secs fish external + # usr time 2,05 secs 128,00 micros 2,05 secs + # sys time 0,70 secs 575,00 micros 0,70 secs + - name: CMake configure + ## Takes 13s on regular GitHub runner + run: cmake -B build -DCMAKE_TOOLCHAIN_FILE=$PWD/vcpkg-build/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=${{ env.BuildType }} -GNinja $CMAKE_USE -DTESTING=$( test "$skip_testing" = skip_testing && echo OFF || echo ON ) -DBENCHMARKING=$( test "$skip_testing" = skip_testing && echo OFF || echo ON ) -DPACKAGE_DEB=ON + #-DCMAKE_VERBOSE_MAKEFILE=ON ## Note: use for debug + - name: CMake build + run: | + set -x + ## reduce memory usage to do not overflow + cmake --build build --config ${{ env.BuildType }} -- -j$(nproc | awk '{printf("%.0f",$1*0.77)}') + echo ::notice::"$(./build/bin/irohad --version)" + ## Debug takes 18m44s on regular GitHub runner + ## Debug takes 7m41s on self-hosted AWS EC2 c5.x4large + ## Release takes 2m58s on self-hosted AWS EC2 c5.x4large + - name: Show free space and disk usage + if: ${{ always() }} + run: | + df -h || true + - name: Install Postgres on Windows + run: choco install postgresql + # - *step_ctest + ## Build and publish docker image named 'hyperledger/iroha' with irohad and iroha tools inside. + ## The result docker image is pushed with tags :branch_name, :pr-NUMBER, :tag_name, + ## and :latest (for git-tags). + ## Those docker image tags could be extended with suffixes with compiler and build type like + ## -gcc10, -clang, -debug, -gcc10-debug. Like :latest-debug, :main-debug, :1.3.0-gcc10-debug. + ## Result image name could look like: hyperledger/iroha:pr-1117, hyperledger/iroha:nightly. + ## Note: image is push only when DockerHub login-token pair available - not to PRs from forks + docker-R: + needs: + - build-UR + - generate_matrixes + runs-on: [self-hosted, Linux] #ubuntu-latest + # strategy: *strategy_ubuntu_release + # if: *if_ubuntu_release + strategy: + fail-fast: false + matrix: ${{ fromJSON( needs.generate_matrixes.outputs.matrix_dockerimage_release ) }} + if: ${{ fromJSON( needs.generate_matrixes.outputs.matrix_dockerimage_release ).include[0] }} + #env: &env_dockerhub_release + # <<: *env_dockerhub + # IMAGE_NAME: iroha + env: + IMAGE_NAME: iroha + steps: + - name: Show context + run: | + echo "::group::GitHub context" + cat <<'END' + ${{ toJson(github) }} + END + echo "::endgroup::" + echo "::group::GitHub needs" + cat <<'END' + ${{ toJson(needs) }} + END + echo "::endgroup::" + - name: System info + run: | + set -x + whoami + id $(whoami) + free || vm_stat | perl -ne '/page size of (\d+)/ and $size=$1; + /Pages\s+([^:]+)[^\d]+(\d+)/ and printf("%-16s % 16.2f Mi\n", "$1:", $2 * $size / 1048576);' + df -h + - name: Build info + run: | + cat << 'END' + ref:${{github.ref}} + sha:${{github.sha}} + run_number:${{github.run_number}} + event_name:${{github.event_name}} + event.action:${{github.event.action}} + event.issue.number:${{ github.event.issue.number }} + END + - name: export CC,BuildType from matrix.buildspec + run: | + echo >>$GITHUB_ENV OS=$(echo ${{matrix.buildspec}} | awk '{print $1}') + echo >>$GITHUB_ENV CC_NAME=$(echo ${{matrix.buildspec}} | awk '{print $2}') + echo >>$GITHUB_ENV BuildType=$(echo ${{matrix.buildspec}} | awk '{print $3}') + features=$(echo ${{matrix.buildspec}} | awk '{print $4}') + case $features in + normal) echo >>$GITHUB_ENV CMAKE_USE=""; features= ;; + ursa) echo >>$GITHUB_ENV CMAKE_USE="-DUSE_LIBURSA=ON";; + burrow) echo >>$GITHUB_ENV CMAKE_USE="-DUSE_BURROW=ON";; + *) echo "::error::Unknown features '$features'"; false ;; + esac + echo >>$GITHUB_ENV features="$features" + echo >>$GITHUB_ENV skip_testing=$(echo ${{matrix.buildspec}} | grep -Fo skip_testing) + - name: REF and SHA of commented PR to ENV + if: github.event.comment + run: > + curl -fsSL ${{github.event.issue.pull_request.url}} -H "Authorization: token ${{github.token}}" | jq -r ' + + "PR_REF="+.head.ref, + "PR_SHA="+.head.sha, + "PR_NUM="+(.number|tostring), + "PR_REPO="+.head.repo.full_name' >>$GITHUB_ENV + - name: Checkout head + uses: actions/checkout@v2 + with: + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} + - name: Generate artifact suffix depending on matrix to env.ARTIFACT_SUFFIX + run: | + set -x + cc=$(echo $CC_NAME | sed -Ee's,[-/],,g' ) + build_type=$(echo $BuildType | tr A-Z a-z | sed -E -es,debug,dbg, -es,release,rel, ) + test $build_type = dbg -o $build_type = rel + uses=$(echo "$features" | tr ' ' - | tr A-Z a-z) + _os=${OS:+-$OS} _cc=${cc:+-$cc} _build_type=${build_type:+-$build_type} _uses=${uses:+-$uses} + echo >>$GITHUB_ENV ARTIFACT_SUFFIX=$_os$_cc$_build_type$_uses + echo >>$GITHUB_ENV _uses_suffix=$_uses + echo >>$GITHUB_ENV _compiler_suffix=$(test $cc != gcc9 && echo $_cc) + echo >>$GITHUB_ENV _debug_suffix=$(test "$build_type" = dbg && echo -debug || true) + - name: Download artifact + uses: actions/download-artifact@v2 + with: + name: iroha-deb${{env.ARTIFACT_SUFFIX}} + - name: Rename artifact debs + run: | + mv *iroha_shepherd.deb docker/release/iroha_shepherd.deb + mv *irohad.deb docker/release/iroha.deb + - name: Determine dockertag + id: dockertag + run: | + echo "::set-output name=dockertag::$dockertag" + echo >>$GITHUB_ENV dockertag=$dockertag + test -n "$DOCKERHUB_ORG" || { + echo ::error::"DOCKERHUB_ORG must contain value" + false + } + env: + dockertag: ${{ hashFiles('docker/release/**') }} + - name: Docker meta + id: meta + uses: docker/metadata-action@v3 + with: + images: | + ${{ env.DOCKERHUB_ORG }}/${{ env.IMAGE_NAME }}${{ env._uses_suffix }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=ref,event=tag + type=schedule + flavor: | + suffix=${{env._compiler_suffix}}${{env._debug_suffix}},onlatest=true + #maybetodo flavor: prefix=${{ env.USES_PREFIX }} ## In case creating repository hyperledger/iroha-burrow denied, Use tag prefix hyperledger/iroha:burrow-xxxx + - uses: docker/metadata-action@v3 + name: Docker meta GHCR + id: meta_ghcr + with: + tags: | + type=ref,event=branch + type=ref,event=pr + type=ref,event=tag + type=schedule + flavor: | + suffix=${{env._compiler_suffix}}${{env._debug_suffix}},onlatest=true + #maybetodo flavor: prefix=${{ env.USES_PREFIX }} ## In case creating repository hyperledger/iroha-burrow denied, Use tag prefix hyperledger/iroha:burrow-xxxx + + images: ghcr.io/${{ github.repository }}${{ env._uses_suffix }} + - name: Login to DockerHub + #if: ${{ secrets.DOCKERHUB_TOKEN != '' && secrets.DOCKERHUB_USERNAME != '' }} + id: docker_login + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Log in to the Container registry GHCR + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Possible WARNING + if: ${{ steps.docker_login.outcome == 'skipped' }} + run: echo "::warning::DOCKERHUB_TOKEN and DOCKERHUB_USERNAME are empty. Will build but NOT push." + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-release-${{env.dockertag}} + restore-keys: ${{ runner.os }}-buildx-release + - id: build_and_push + name: Build and push + uses: docker/build-push-action@v2 + with: + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + # env: + # DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + # DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + + context: docker/release/ + push: ${{ steps.docker_login.outcome == 'success' }} + - uses: docker/build-push-action@v2 + id: build_and_push_ghcr + name: Build and push to GHCR + with: + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new + push: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo == github.event.pull_request.base.repo }} + tags: ${{ steps.meta_ghcr.outputs.tags }} + labels: ${{ steps.meta_ghcr.outputs.labels }} + # env: + # DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + # DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + + context: docker/release/ + - # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache + docker-D: + runs-on: [self-hosted, Linux] #ubuntu-latest + #env: &env_dockerhub_release + # <<: *env_dockerhub + # IMAGE_NAME: iroha + env: + IMAGE_NAME: iroha + steps: + - name: Show context + run: | + echo "::group::GitHub context" + cat <<'END' + ${{ toJson(github) }} + END + echo "::endgroup::" + echo "::group::GitHub needs" + cat <<'END' + ${{ toJson(needs) }} + END + echo "::endgroup::" + - name: System info + run: | + set -x + whoami + id $(whoami) + free || vm_stat | perl -ne '/page size of (\d+)/ and $size=$1; + /Pages\s+([^:]+)[^\d]+(\d+)/ and printf("%-16s % 16.2f Mi\n", "$1:", $2 * $size / 1048576);' + df -h + - name: Build info + run: | + cat << 'END' + ref:${{github.ref}} + sha:${{github.sha}} + run_number:${{github.run_number}} + event_name:${{github.event_name}} + event.action:${{github.event.action}} + event.issue.number:${{ github.event.issue.number }} + END + - name: export CC,BuildType from matrix.buildspec + run: | + echo >>$GITHUB_ENV OS=$(echo ${{matrix.buildspec}} | awk '{print $1}') + echo >>$GITHUB_ENV CC_NAME=$(echo ${{matrix.buildspec}} | awk '{print $2}') + echo >>$GITHUB_ENV BuildType=$(echo ${{matrix.buildspec}} | awk '{print $3}') + features=$(echo ${{matrix.buildspec}} | awk '{print $4}') + case $features in + normal) echo >>$GITHUB_ENV CMAKE_USE=""; features= ;; + ursa) echo >>$GITHUB_ENV CMAKE_USE="-DUSE_LIBURSA=ON";; + burrow) echo >>$GITHUB_ENV CMAKE_USE="-DUSE_BURROW=ON";; + *) echo "::error::Unknown features '$features'"; false ;; + esac + echo >>$GITHUB_ENV features="$features" + echo >>$GITHUB_ENV skip_testing=$(echo ${{matrix.buildspec}} | grep -Fo skip_testing) + - name: REF and SHA of commented PR to ENV + if: github.event.comment + run: > + curl -fsSL ${{github.event.issue.pull_request.url}} -H "Authorization: token ${{github.token}}" | jq -r ' + + "PR_REF="+.head.ref, + "PR_SHA="+.head.sha, + "PR_NUM="+(.number|tostring), + "PR_REPO="+.head.repo.full_name' >>$GITHUB_ENV + - name: Checkout head + uses: actions/checkout@v2 + with: + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} + - name: Generate artifact suffix depending on matrix to env.ARTIFACT_SUFFIX + run: | + set -x + cc=$(echo $CC_NAME | sed -Ee's,[-/],,g' ) + build_type=$(echo $BuildType | tr A-Z a-z | sed -E -es,debug,dbg, -es,release,rel, ) + test $build_type = dbg -o $build_type = rel + uses=$(echo "$features" | tr ' ' - | tr A-Z a-z) + _os=${OS:+-$OS} _cc=${cc:+-$cc} _build_type=${build_type:+-$build_type} _uses=${uses:+-$uses} + echo >>$GITHUB_ENV ARTIFACT_SUFFIX=$_os$_cc$_build_type$_uses + echo >>$GITHUB_ENV _uses_suffix=$_uses + echo >>$GITHUB_ENV _compiler_suffix=$(test $cc != gcc9 && echo $_cc) + echo >>$GITHUB_ENV _debug_suffix=$(test "$build_type" = dbg && echo -debug || true) + - name: Download artifact + uses: actions/download-artifact@v2 + with: + name: iroha-deb${{env.ARTIFACT_SUFFIX}} + - name: Rename artifact debs + run: | + mv *iroha_shepherd.deb docker/release/iroha_shepherd.deb + mv *irohad.deb docker/release/iroha.deb + - name: Determine dockertag + id: dockertag + run: | + echo "::set-output name=dockertag::$dockertag" + echo >>$GITHUB_ENV dockertag=$dockertag + test -n "$DOCKERHUB_ORG" || { + echo ::error::"DOCKERHUB_ORG must contain value" + false + } + env: + dockertag: ${{ hashFiles('docker/release/**') }} + - name: Docker meta + id: meta + uses: docker/metadata-action@v3 + with: + images: | + ${{ env.DOCKERHUB_ORG }}/${{ env.IMAGE_NAME }}${{ env._uses_suffix }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=ref,event=tag + type=schedule + flavor: | + suffix=${{env._compiler_suffix}}${{env._debug_suffix}},onlatest=true + #maybetodo flavor: prefix=${{ env.USES_PREFIX }} ## In case creating repository hyperledger/iroha-burrow denied, Use tag prefix hyperledger/iroha:burrow-xxxx + - uses: docker/metadata-action@v3 + name: Docker meta GHCR + id: meta_ghcr + with: + tags: | + type=ref,event=branch + type=ref,event=pr + type=ref,event=tag + type=schedule + flavor: | + suffix=${{env._compiler_suffix}}${{env._debug_suffix}},onlatest=true + #maybetodo flavor: prefix=${{ env.USES_PREFIX }} ## In case creating repository hyperledger/iroha-burrow denied, Use tag prefix hyperledger/iroha:burrow-xxxx + + images: ghcr.io/${{ github.repository }}${{ env._uses_suffix }} + - name: Login to DockerHub + #if: ${{ secrets.DOCKERHUB_TOKEN != '' && secrets.DOCKERHUB_USERNAME != '' }} + id: docker_login + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Log in to the Container registry GHCR + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Possible WARNING + if: ${{ steps.docker_login.outcome == 'skipped' }} + run: echo "::warning::DOCKERHUB_TOKEN and DOCKERHUB_USERNAME are empty. Will build but NOT push." + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-release-${{env.dockertag}} + restore-keys: ${{ runner.os }}-buildx-release + - id: build_and_push + name: Build and push + uses: docker/build-push-action@v2 + with: + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + # env: + # DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + # DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + + context: docker/release/ + push: ${{ steps.docker_login.outcome == 'success' }} + - uses: docker/build-push-action@v2 + id: build_and_push_ghcr + name: Build and push to GHCR + with: + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new + push: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo == github.event.pull_request.base.repo }} + tags: ${{ steps.meta_ghcr.outputs.tags }} + labels: ${{ steps.meta_ghcr.outputs.labels }} + # env: + # DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + # DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + + context: docker/release/ + - # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache + needs: + - build-UD + - generate_matrixes + # strategy: *strategy_ubuntu_debug + # if: *if_ubuntu_debug + strategy: + fail-fast: false + matrix: ${{ fromJSON( needs.generate_matrixes.outputs.matrix_dockerimage_debug ) }} + if: ${{ fromJSON( needs.generate_matrixes.outputs.matrix_dockerimage_debug ).include[0] }} From 7ad48dd9ba32ef4dacd5920e0c56c10f0f815d69 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 30 Mar 2022 09:35:56 +0300 Subject: [PATCH 069/130] Build all Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 4 ++-- .github/workflows/build-iroha1-fork.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index f370a7a80a4..7bf1c036592 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -98,8 +98,8 @@ jobs: true else #echo >/tmp/comment_body "/build debug; /build ubuntu release debug normal" - #echo >/tmp/comment_body "/build all" - echo >/tmp/comment_body "/build ubuntu debug clang-10 normal" + echo >/tmp/comment_body "/build all" + #echo >/tmp/comment_body "/build ubuntu debug clang-10 normal" fi ;; esac - diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index c8e17006f02..1fbaf60897d 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -120,8 +120,8 @@ jobs: true else #echo >/tmp/comment_body "/build debug; /build ubuntu release debug normal" - #echo >/tmp/comment_body "/build all" - echo >/tmp/comment_body "/build ubuntu debug clang-10 normal" + echo >/tmp/comment_body "/build all" + #echo >/tmp/comment_body "/build ubuntu debug clang-10 normal" fi ;; esac - name: Generate matrixes From 9f44b0549d22588cc893c61162cd7bca40b0f4fa Mon Sep 17 00:00:00 2001 From: safinsaf Date: Thu, 31 Mar 2022 08:08:01 +0300 Subject: [PATCH 070/130] Run only one workflow Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 14 ++++++++++++++ .github/build-iroha1.src.yml | 16 +++++++++++++++- .github/workflows/build-iroha1-fork.yml | 11 +++++++++++ .github/workflows/build-iroha1.yml | 13 ++++++++++++- 4 files changed, 52 insertions(+), 2 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 7bf1c036592..3c4fc9edd8c 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -12,6 +12,20 @@ jobs: ## and that is why there is a workaround with make-workflows.sh ## You should `pre-commit install` or use `pre-commit-hook.sh`, ## anyway please read .github/README.md + + check_if_pull_request_comes_from_the_same_repo: + runs-on: ubuntu-20.04 #ubuntu-latest + name: Pull requests from forks should use other workflow + if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo == github.event.pull_request.base.repo }} + steps: + - + run: | + cat < Date: Thu, 31 Mar 2022 08:24:00 +0300 Subject: [PATCH 071/130] Run only one workflow Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 1 + .github/build-iroha1.src.yml | 1 + .github/workflows/build-iroha1-fork.yml | 1 + .github/workflows/build-iroha1.yml | 1 + 4 files changed, 4 insertions(+) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 3c4fc9edd8c..70cdb692734 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -29,6 +29,7 @@ jobs: check_workflow_yaml_coressponds_to_src_yaml: runs-on: ubuntu-20.04 #ubuntu-latest name: Check if github workflows were properly made from sources + needs: check_if_pull_request_comes_from_the_same_repo steps: - &step_show_context name: Show context diff --git a/.github/build-iroha1.src.yml b/.github/build-iroha1.src.yml index 34ffc74057f..8b4f37976b5 100644 --- a/.github/build-iroha1.src.yml +++ b/.github/build-iroha1.src.yml @@ -106,6 +106,7 @@ jobs: ## You should `pre-commit install` or use `pre-commit-hook.sh`, ## anyway please read .github/README.md check_workflow_yaml_coressponds_to_src_yaml: + needs: check_if_pull_request_comes_from_fork runs-on: ubuntu-20.04 #ubuntu-latest name: Check if github workflows were properly made from sources steps: diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index e9b64a5f2c1..32150b0e758 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -26,6 +26,7 @@ jobs: check_workflow_yaml_coressponds_to_src_yaml: runs-on: ubuntu-20.04 #ubuntu-latest name: Check if github workflows were properly made from sources + needs: check_if_pull_request_comes_from_the_same_repo steps: - name: Show context run: | diff --git a/.github/workflows/build-iroha1.yml b/.github/workflows/build-iroha1.yml index 722ac34cadb..987dc5b408c 100644 --- a/.github/workflows/build-iroha1.yml +++ b/.github/workflows/build-iroha1.yml @@ -104,6 +104,7 @@ jobs: ## You should `pre-commit install` or use `pre-commit-hook.sh`, ## anyway please read .github/README.md check_workflow_yaml_coressponds_to_src_yaml: + needs: check_if_pull_request_comes_from_fork runs-on: ubuntu-20.04 #ubuntu-latest name: Check if github workflows were properly made from sources steps: From 2af6953440513bb9b6a48da2358ba0225ba87f04 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Thu, 31 Mar 2022 08:34:10 +0300 Subject: [PATCH 072/130] Skip not-needed jobs Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 10 +++++----- .github/build-iroha1.src.yml | 8 ++++---- .github/workflows/build-iroha1-fork.yml | 13 ++++--------- .github/workflows/build-iroha1.yml | 8 ++++---- 4 files changed, 17 insertions(+), 22 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 70cdb692734..454fd5a5b23 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -13,23 +13,23 @@ jobs: ## You should `pre-commit install` or use `pre-commit-hook.sh`, ## anyway please read .github/README.md - check_if_pull_request_comes_from_the_same_repo: + check_if_pull_request_comes_from_fork: runs-on: ubuntu-20.04 #ubuntu-latest name: Pull requests from forks should use other workflow - if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo == github.event.pull_request.base.repo }} + if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo != github.event.pull_request.base.repo }} steps: - run: | cat < Date: Thu, 31 Mar 2022 08:55:07 +0300 Subject: [PATCH 073/130] Add comments to new checks Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 15 +++++++-------- .github/build-iroha1.src.yml | 6 ++---- .github/workflows/build-iroha1-fork.yml | 13 ++++++++----- .github/workflows/build-iroha1.yml | 6 ++---- 4 files changed, 19 insertions(+), 21 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 454fd5a5b23..c3baee6a27a 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -8,11 +8,9 @@ env: DOCKERHUB_ORG: hyperledger jobs: - ## GitHub Actions Workflow does not support yaml anchors - ## and that is why there is a workaround with make-workflows.sh - ## You should `pre-commit install` or use `pre-commit-hook.sh`, - ## anyway please read .github/README.md + ## This workflow is created for pull requests from forks only and has less permissions + ## This step allows to skip the workflow completely for pull_requests from th same repo check_if_pull_request_comes_from_fork: runs-on: ubuntu-20.04 #ubuntu-latest name: Pull requests from forks should use other workflow @@ -20,12 +18,13 @@ jobs: steps: - run: | - cat < Date: Thu, 31 Mar 2022 09:01:32 +0300 Subject: [PATCH 074/130] Make the new step first Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 1 + .github/build-iroha1.src.yml | 1 + .github/workflows/build-iroha1-fork.yml | 1 + .github/workflows/build-iroha1.yml | 1 + 4 files changed, 4 insertions(+) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index c3baee6a27a..aaa3f971529 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -72,6 +72,7 @@ jobs: generate_matrixes: runs-on: ubuntu-20.04 #ubuntu-latest + needs: check_if_pull_request_comes_from_fork #container: ubuntu:latest if: ${{ (github.event_name != 'comment') || ( github.event.comment && github.event.issue.pull_request && diff --git a/.github/build-iroha1.src.yml b/.github/build-iroha1.src.yml index 39903cd1907..be3e613dddc 100644 --- a/.github/build-iroha1.src.yml +++ b/.github/build-iroha1.src.yml @@ -172,6 +172,7 @@ jobs: ## - on workflow_dispatch according to its build_spec ## - on schedule '/build all' generate_matrixes: + needs: check_if_pull_request_comes_from_the_same_repo runs-on: ubuntu-20.04 #ubuntu-latest #container: ubuntu:latest if: ${{ (github.event_name != 'comment') || ( github.event.comment && diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 72854a55ca5..73af10c6312 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -71,6 +71,7 @@ jobs: [[ $(./.github/make-workflows.sh -x --worktree) = *"everything is up to date" ]] generate_matrixes: runs-on: ubuntu-20.04 #ubuntu-latest + needs: check_if_pull_request_comes_from_fork #container: ubuntu:latest if: ${{ (github.event_name != 'comment') || ( github.event.comment && github.event.issue.pull_request && startsWith(github.event.comment.body, '/build') ) }} steps: diff --git a/.github/workflows/build-iroha1.yml b/.github/workflows/build-iroha1.yml index 5a9aeba7c5e..14d210b025d 100644 --- a/.github/workflows/build-iroha1.yml +++ b/.github/workflows/build-iroha1.yml @@ -159,6 +159,7 @@ jobs: ## - on workflow_dispatch according to its build_spec ## - on schedule '/build all' generate_matrixes: + needs: check_if_pull_request_comes_from_the_same_repo runs-on: ubuntu-20.04 #ubuntu-latest #container: ubuntu:latest if: ${{ (github.event_name != 'comment') || ( github.event.comment && github.event.issue.pull_request && startsWith(github.event.comment.body, '/build') ) }} From 73526f5fdade78916e6c852ae590850ce77a6ee4 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Thu, 31 Mar 2022 10:05:53 +0300 Subject: [PATCH 075/130] Do not allow to change iroha-builder Dockerfile Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 56 ++++++------------------- .github/workflows/build-iroha1-fork.yml | 51 +++++----------------- 2 files changed, 22 insertions(+), 85 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index aaa3f971529..6213b304302 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -55,12 +55,12 @@ jobs: "PR_NUM="+(.number|tostring), "PR_REPO="+.head.repo.full_name' >>$GITHUB_ENV - *step_show_context - - &step_checkout_base - name: Checkout base + - &step_checkout_head + name: Checkout head uses: actions/checkout@v2 - with: &step_checkout_with_base - ref: ${{env.PR_REF}} ## not empty on issue_comment, else default value GITHUB_REF - repository: ${{env.PR_REPO}} ## not empty on issue_comment, else default value github.repository, required by forks + with: &step_checkout_with_head + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} - run: sudo snap install yq - @@ -80,7 +80,7 @@ jobs: steps: - *step_show_context - *step_detect_commented_pr - - *step_checkout_base + - *step_checkout_head - name: Generate matrix for build triggered by chat-ops - comment to PR if: github.event.issue.pull_request && github.event.comment @@ -113,7 +113,7 @@ jobs: true else #echo >/tmp/comment_body "/build debug; /build ubuntu release debug normal" - echo >/tmp/comment_body "/build all" + echo >/tmp/comment_body "/build all skip_testing" #echo >/tmp/comment_body "/build ubuntu debug clang-10 normal" fi ;; esac @@ -163,10 +163,6 @@ jobs: Docker-iroha-builder: needs: check_workflow_yaml_coressponds_to_src_yaml runs-on: ubuntu-20.04 #ubuntu-latest #[ self-hosted, Linux ] - # env: &env_dockerhub - # DOCKERHUB_ORG: DOCKERHUB_ORG ## Must be hyperledger, also can use iroha1, cannot use ${{ secrets.DOCKERHUB_ORG }} - # DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - # DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} steps: - *step_show_context - &step_system_info @@ -190,12 +186,12 @@ jobs: event.issue.number:${{ github.event.issue.number }} END - *step_detect_commented_pr - - &step_checkout_head - name: Checkout head + - &step_checkout_base + name: Checkout base uses: actions/checkout@v2 - with: &step_checkout_with_head - ref: ${{github.event.pull_request.head.ref}} - repository: ${{github.event.pull_request.head.repo.full_name}} + with: &step_checkout_with_base + ref: ${{env.PR_REF}} ## not empty on issue_comment, else default value GITHUB_REF + repository: ${{env.PR_REPO}} ## not empty on issue_comment, else default value github.repository, required by forks - &step_docker_tag name: Determine dockertag id: dockertag @@ -302,34 +298,6 @@ jobs: run: | echo "::set-output name=container::$DOCKERHUB_ORG/iroha-builder:$dockertag" docker pull "$DOCKERHUB_ORG/iroha-builder:$dockertag" - - - name: Possible ERROR, Dockerfile edited, image was build, but seems not pushed, CANNOT PULL. - if: failure() - #if: ${{ steps.docker_login.outcome != 'success' || steps.build_and_push.outcome != 'success' }} - env: - container: ${{steps.dockertag_already.outputs.container}} - dockertag: ${{env.dockertag}} - run: | - cat </tmp/comment_body "/build all" + echo >/tmp/comment_body "/build all skip_testing" #echo >/tmp/comment_body "/build ubuntu debug clang-10 normal" fi ;; esac @@ -177,10 +177,6 @@ jobs: Docker-iroha-builder: needs: check_workflow_yaml_coressponds_to_src_yaml runs-on: ubuntu-20.04 #ubuntu-latest #[ self-hosted, Linux ] - # env: &env_dockerhub - # DOCKERHUB_ORG: DOCKERHUB_ORG ## Must be hyperledger, also can use iroha1, cannot use ${{ secrets.DOCKERHUB_ORG }} - # DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - # DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} steps: - name: Show context run: | @@ -221,11 +217,11 @@ jobs: "PR_SHA="+.head.sha, "PR_NUM="+(.number|tostring), "PR_REPO="+.head.repo.full_name' >>$GITHUB_ENV - - name: Checkout head + - name: Checkout base uses: actions/checkout@v2 with: - ref: ${{github.event.pull_request.head.ref}} - repository: ${{github.event.pull_request.head.repo.full_name}} + ref: ${{env.PR_REF}} ## not empty on issue_comment, else default value GITHUB_REF + repository: ${{env.PR_REPO}} ## not empty on issue_comment, else default value github.repository, required by forks - name: Determine dockertag id: dockertag env: @@ -334,33 +330,6 @@ jobs: run: | echo "::set-output name=container::$DOCKERHUB_ORG/iroha-builder:$dockertag" docker pull "$DOCKERHUB_ORG/iroha-builder:$dockertag" - - name: Possible ERROR, Dockerfile edited, image was build, but seems not pushed, CANNOT PULL. - if: failure() - #if: ${{ steps.docker_login.outcome != 'success' || steps.build_and_push.outcome != 'success' }} - env: - container: ${{steps.dockertag_already.outputs.container}} - dockertag: ${{env.dockertag}} - run: | - cat < Date: Thu, 31 Mar 2022 10:17:20 +0300 Subject: [PATCH 076/130] Do not allow to change iroha Dockerfile Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 2 +- .github/workflows/build-iroha1-fork.yml | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 6213b304302..3eb6d9c1c5d 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -750,7 +750,7 @@ jobs: - *step_build_info - *step_env_from_buildspec - *step_detect_commented_pr - - *step_checkout_head + - *step_checkout_base - *step_artifact_suffix - name: Download artifact uses: actions/download-artifact@v2 diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 520a3657fca..4d3aea08acc 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -1389,11 +1389,11 @@ jobs: "PR_SHA="+.head.sha, "PR_NUM="+(.number|tostring), "PR_REPO="+.head.repo.full_name' >>$GITHUB_ENV - - name: Checkout head + - name: Checkout base uses: actions/checkout@v2 with: - ref: ${{github.event.pull_request.head.ref}} - repository: ${{github.event.pull_request.head.repo.full_name}} + ref: ${{env.PR_REF}} ## not empty on issue_comment, else default value GITHUB_REF + repository: ${{env.PR_REPO}} ## not empty on issue_comment, else default value github.repository, required by forks - name: Generate artifact suffix depending on matrix to env.ARTIFACT_SUFFIX run: | set -x @@ -1573,11 +1573,11 @@ jobs: "PR_SHA="+.head.sha, "PR_NUM="+(.number|tostring), "PR_REPO="+.head.repo.full_name' >>$GITHUB_ENV - - name: Checkout head + - name: Checkout base uses: actions/checkout@v2 with: - ref: ${{github.event.pull_request.head.ref}} - repository: ${{github.event.pull_request.head.repo.full_name}} + ref: ${{env.PR_REF}} ## not empty on issue_comment, else default value GITHUB_REF + repository: ${{env.PR_REPO}} ## not empty on issue_comment, else default value github.repository, required by forks - name: Generate artifact suffix depending on matrix to env.ARTIFACT_SUFFIX run: | set -x From cb28e1a34a4069840e80d4feabdc6bf117e29f56 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Thu, 31 Mar 2022 11:10:17 +0300 Subject: [PATCH 077/130] Debug iroha workflow not running Signed-off-by: safinsaf --- .github/build-iroha1.src.yml | 15 ++++++++++++++- .github/workflows/build-iroha1.yml | 14 +++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/.github/build-iroha1.src.yml b/.github/build-iroha1.src.yml index be3e613dddc..90c73deaff5 100644 --- a/.github/build-iroha1.src.yml +++ b/.github/build-iroha1.src.yml @@ -93,8 +93,21 @@ jobs: check_if_pull_request_comes_from_the_same_repo: runs-on: ubuntu-20.04 #ubuntu-latest name: Pull requests from forks should use other workflow - if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo == github.event.pull_request.base.repo }} + #if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo == github.event.pull_request.base.repo }} steps: + - + name: Show context + run: | + echo "::group::GitHub context" + cat <<'END' + ${{ toJson(github) }} + END + echo "::endgroup::" + echo "::group::GitHub needs" + cat <<'END' + ${{ toJson(needs) }} + END + echo "::endgroup::" - run: | true diff --git a/.github/workflows/build-iroha1.yml b/.github/workflows/build-iroha1.yml index 14d210b025d..d300963d70e 100644 --- a/.github/workflows/build-iroha1.yml +++ b/.github/workflows/build-iroha1.yml @@ -93,8 +93,20 @@ jobs: check_if_pull_request_comes_from_the_same_repo: runs-on: ubuntu-20.04 #ubuntu-latest name: Pull requests from forks should use other workflow - if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo == github.event.pull_request.base.repo }} + #if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo == github.event.pull_request.base.repo }} steps: + - name: Show context + run: | + echo "::group::GitHub context" + cat <<'END' + ${{ toJson(github) }} + END + echo "::endgroup::" + echo "::group::GitHub needs" + cat <<'END' + ${{ toJson(needs) }} + END + echo "::endgroup::" - run: | true ## GitHub Actions Workflow does not support yaml anchors From 4d4ecec1088736ac78a9af0237e97c33b186be2d Mon Sep 17 00:00:00 2001 From: safinsaf Date: Thu, 31 Mar 2022 11:15:19 +0300 Subject: [PATCH 078/130] Debug iroha workflow not running Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 2 +- .github/build-iroha1.src.yml | 2 +- .github/workflows/build-iroha1-fork.yml | 2 +- .github/workflows/build-iroha1.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 3eb6d9c1c5d..1e752c7b740 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -14,7 +14,7 @@ jobs: check_if_pull_request_comes_from_fork: runs-on: ubuntu-20.04 #ubuntu-latest name: Pull requests from forks should use other workflow - if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo != github.event.pull_request.base.repo }} + if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name }} steps: - run: | diff --git a/.github/build-iroha1.src.yml b/.github/build-iroha1.src.yml index 90c73deaff5..ffe021c8d15 100644 --- a/.github/build-iroha1.src.yml +++ b/.github/build-iroha1.src.yml @@ -93,7 +93,7 @@ jobs: check_if_pull_request_comes_from_the_same_repo: runs-on: ubuntu-20.04 #ubuntu-latest name: Pull requests from forks should use other workflow - #if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo == github.event.pull_request.base.repo }} + if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name }} steps: - name: Show context diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 4d3aea08acc..035fd35f506 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -13,7 +13,7 @@ jobs: check_if_pull_request_comes_from_fork: runs-on: ubuntu-20.04 #ubuntu-latest name: Pull requests from forks should use other workflow - if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo != github.event.pull_request.base.repo }} + if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name }} steps: - run: | true diff --git a/.github/workflows/build-iroha1.yml b/.github/workflows/build-iroha1.yml index d300963d70e..b5c29e7a56a 100644 --- a/.github/workflows/build-iroha1.yml +++ b/.github/workflows/build-iroha1.yml @@ -93,7 +93,7 @@ jobs: check_if_pull_request_comes_from_the_same_repo: runs-on: ubuntu-20.04 #ubuntu-latest name: Pull requests from forks should use other workflow - #if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo == github.event.pull_request.base.repo }} + if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name }} steps: - name: Show context run: | From fe739775318745a5b6ff9b1335b27c268c205f78 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Fri, 1 Apr 2022 09:26:51 +0300 Subject: [PATCH 079/130] Show all changed files Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 25 ++++++++++++++++++++++--- .github/workflows/build-iroha1-fork.yml | 18 ++++++++++++++++-- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 1e752c7b740..8da60a29552 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -2,7 +2,7 @@ name: Iroha1-fork on: pull_request_target: - branches: [ feature/DOPS-1651/enable-fork-build ] ## target branches + branches: [ main, support/1.*, edge, develop, feature/DOPS-1651/enable-fork-build ] ## target branches env: DOCKERHUB_ORG: hyperledger @@ -10,7 +10,7 @@ env: jobs: ## This workflow is created for pull requests from forks only and has less permissions - ## This step allows to skip the workflow completely for pull_requests from th same repo + ## This step allows to skip the workflow completely for pull_requests from the same repo check_if_pull_request_comes_from_fork: runs-on: ubuntu-20.04 #ubuntu-latest name: Pull requests from forks should use other workflow @@ -19,7 +19,25 @@ jobs: - run: | true + + - &step_checkout_head + name: Checkout head + uses: actions/checkout@v2 + with: &step_checkout_with_head + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} + + - + name: Get changed files + id: changed-files + uses: tj-actions/changed-files@v18.6 + - + name: List all changed files + run: | + for file in ${{ steps.changed-files.outputs.all_changed_files }}; do + echo "$file was changed" + done ## GitHub Actions Workflow does not support yaml anchors ## and that is why there is a workaround with make-workflows.sh @@ -55,7 +73,8 @@ jobs: "PR_NUM="+(.number|tostring), "PR_REPO="+.head.repo.full_name' >>$GITHUB_ENV - *step_show_context - - &step_checkout_head + #- &step_checkout_head + - name: Checkout head uses: actions/checkout@v2 with: &step_checkout_with_head diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 035fd35f506..12210c9ede5 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -4,12 +4,12 @@ name: Iroha1-fork on: pull_request_target: - branches: [feature/DOPS-1651/enable-fork-build] ## target branches + branches: [main, support/1.*, edge, develop, feature/DOPS-1651/enable-fork-build] ## target branches env: DOCKERHUB_ORG: hyperledger jobs: ## This workflow is created for pull requests from forks only and has less permissions - ## This step allows to skip the workflow completely for pull_requests from th same repo + ## This step allows to skip the workflow completely for pull_requests from the same repo check_if_pull_request_comes_from_fork: runs-on: ubuntu-20.04 #ubuntu-latest name: Pull requests from forks should use other workflow @@ -17,6 +17,19 @@ jobs: steps: - run: | true + - name: Checkout head + uses: actions/checkout@v2 + with: + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} + - name: Get changed files + id: changed-files + uses: tj-actions/changed-files@v18.6 + - name: List all changed files + run: | + for file in ${{ steps.changed-files.outputs.all_changed_files }}; do + echo "$file was changed" + done ## GitHub Actions Workflow does not support yaml anchors ## and that is why there is a workaround with make-workflows.sh ## You should `pre-commit install` or use `pre-commit-hook.sh`, @@ -59,6 +72,7 @@ jobs: ${{ toJson(needs) }} END echo "::endgroup::" + #- &step_checkout_head - name: Checkout head uses: actions/checkout@v2 with: From 32f6c5db1aef0218dffcf477942a622fac5d4c7b Mon Sep 17 00:00:00 2001 From: safinsaf Date: Fri, 1 Apr 2022 09:32:59 +0300 Subject: [PATCH 080/130] Fetch history of commits for diff Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 7 +++---- .github/workflows/build-iroha1-fork.yml | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 8da60a29552..c92054d5419 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -20,13 +20,13 @@ jobs: run: | true - - &step_checkout_head + - name: Checkout head uses: actions/checkout@v2 with: &step_checkout_with_head ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} - + fetch-depth: 0 - name: Get changed files id: changed-files @@ -73,8 +73,7 @@ jobs: "PR_NUM="+(.number|tostring), "PR_REPO="+.head.repo.full_name' >>$GITHUB_ENV - *step_show_context - #- &step_checkout_head - - + - &step_checkout_head name: Checkout head uses: actions/checkout@v2 with: &step_checkout_with_head diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 12210c9ede5..352142bc1f3 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -22,6 +22,7 @@ jobs: with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} + fetch-depth: 0 - name: Get changed files id: changed-files uses: tj-actions/changed-files@v18.6 @@ -72,7 +73,6 @@ jobs: ${{ toJson(needs) }} END echo "::endgroup::" - #- &step_checkout_head - name: Checkout head uses: actions/checkout@v2 with: From 734382386d2c9f453b6f832740bae04f23a7e182 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Fri, 1 Apr 2022 09:43:17 +0300 Subject: [PATCH 081/130] Try checkout base for mode Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 9 ++++----- .github/workflows/build-iroha1-fork.yml | 7 +++---- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index c92054d5419..11fe7dde264 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -21,12 +21,11 @@ jobs: true - - name: Checkout head + name: Checkout base uses: actions/checkout@v2 - with: &step_checkout_with_head - ref: ${{github.event.pull_request.head.ref}} - repository: ${{github.event.pull_request.head.repo.full_name}} - fetch-depth: 0 + with: &step_checkout_with_base + ref: ${{env.PR_REF}} ## not empty on issue_comment, else default value GITHUB_REF + repository: ${{env.PR_REPO}} ## not empty on issue_comment, else default value github.repository, required by forks - name: Get changed files id: changed-files diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 352142bc1f3..7e4e1c2c570 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -17,12 +17,11 @@ jobs: steps: - run: | true - - name: Checkout head + - name: Checkout base uses: actions/checkout@v2 with: - ref: ${{github.event.pull_request.head.ref}} - repository: ${{github.event.pull_request.head.repo.full_name}} - fetch-depth: 0 + ref: ${{env.PR_REF}} ## not empty on issue_comment, else default value GITHUB_REF + repository: ${{env.PR_REPO}} ## not empty on issue_comment, else default value github.repository, required by forks - name: Get changed files id: changed-files uses: tj-actions/changed-files@v18.6 From c52ad7dc89d419146fe0988be3e3706c6e370357 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Fri, 1 Apr 2022 09:49:42 +0300 Subject: [PATCH 082/130] Try checkout v3 on head for diff Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 10 +++++----- .github/workflows/build-iroha1-fork.yml | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 11fe7dde264..e0721f78fb9 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -21,11 +21,11 @@ jobs: true - - name: Checkout base - uses: actions/checkout@v2 - with: &step_checkout_with_base - ref: ${{env.PR_REF}} ## not empty on issue_comment, else default value GITHUB_REF - repository: ${{env.PR_REPO}} ## not empty on issue_comment, else default value github.repository, required by forks + name: Checkout head + uses: actions/checkout@v3 + with: + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} - name: Get changed files id: changed-files diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 7e4e1c2c570..a143fc978cd 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -17,11 +17,11 @@ jobs: steps: - run: | true - - name: Checkout base - uses: actions/checkout@v2 + - name: Checkout head + uses: actions/checkout@v3 with: - ref: ${{env.PR_REF}} ## not empty on issue_comment, else default value GITHUB_REF - repository: ${{env.PR_REPO}} ## not empty on issue_comment, else default value github.repository, required by forks + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} - name: Get changed files id: changed-files uses: tj-actions/changed-files@v18.6 From 5a9e1a9cb6caa42fbb37ad2f19d21a6825bc2b5a Mon Sep 17 00:00:00 2001 From: safinsaf Date: Fri, 1 Apr 2022 09:54:22 +0300 Subject: [PATCH 083/130] Allow use fork point Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 2 ++ .github/workflows/build-iroha1-fork.yml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index e0721f78fb9..2f8df051257 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -30,6 +30,8 @@ jobs: name: Get changed files id: changed-files uses: tj-actions/changed-files@v18.6 + with: + use_fork_point: True - name: List all changed files diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index a143fc978cd..27c0ec10354 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -25,6 +25,8 @@ jobs: - name: Get changed files id: changed-files uses: tj-actions/changed-files@v18.6 + with: + use_fork_point: True - name: List all changed files run: | for file in ${{ steps.changed-files.outputs.all_changed_files }}; do From 6fb12884c3d112c8244ef1ea13a7893de2a81d67 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Fri, 1 Apr 2022 10:08:33 +0300 Subject: [PATCH 084/130] Find fork point Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 6 ++++++ .github/workflows/build-iroha1-fork.yml | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 2f8df051257..511162f8b1e 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -26,6 +26,12 @@ jobs: with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} + + - name: Find common ancestor + env: + FORK_BASE_BRANCH: ${{ github.base_ref }} + run: git merge-base --fork-point origin/$BASE_BRANCH + - name: Get changed files id: changed-files diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 27c0ec10354..91a72c1e535 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -22,6 +22,10 @@ jobs: with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} + - name: Find common ancestor + env: + FORK_BASE_BRANCH: ${{ github.base_ref }} + run: git merge-base --fork-point origin/$BASE_BRANCH - name: Get changed files id: changed-files uses: tj-actions/changed-files@v18.6 From db27f128a5e320b3787321f3ad60de5f3c844279 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Fri, 1 Apr 2022 10:11:23 +0300 Subject: [PATCH 085/130] Find fork point Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 2 +- .github/workflows/build-iroha1-fork.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 511162f8b1e..a2b1d8703c1 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -30,7 +30,7 @@ jobs: - name: Find common ancestor env: FORK_BASE_BRANCH: ${{ github.base_ref }} - run: git merge-base --fork-point origin/$BASE_BRANCH + run: git merge-base --fork-point origin/$FORK_BASE_BRANCH - name: Get changed files diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 91a72c1e535..83a376ecbfe 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -25,7 +25,7 @@ jobs: - name: Find common ancestor env: FORK_BASE_BRANCH: ${{ github.base_ref }} - run: git merge-base --fork-point origin/$BASE_BRANCH + run: git merge-base --fork-point origin/$FORK_BASE_BRANCH - name: Get changed files id: changed-files uses: tj-actions/changed-files@v18.6 From bc06d441c482edf5f427c118ccf2a64c7588917c Mon Sep 17 00:00:00 2001 From: safinsaf Date: Mon, 4 Apr 2022 10:24:26 +0300 Subject: [PATCH 086/130] Fix finding ancestor Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 10 +++++++++- .github/workflows/build-iroha1-fork.yml | 7 ++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index a2b1d8703c1..7180e4a1fad 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -27,10 +27,18 @@ jobs: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} + - + name: Set second remote + with: + url: ${{github.event.pull_request.base.repo.ssh_url}} + run: | + git remote add base {{url}} + + - name: Find common ancestor env: FORK_BASE_BRANCH: ${{ github.base_ref }} - run: git merge-base --fork-point origin/$FORK_BASE_BRANCH + run: git merge-base --fork-point base/$FORK_BASE_BRANCH - name: Get changed files diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 83a376ecbfe..fb850bb2de8 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -22,10 +22,15 @@ jobs: with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} + - name: Set second remote + with: + url: ${{github.event.pull_request.base.repo.ssh_url}} + run: | + git remote add base {{url}} - name: Find common ancestor env: FORK_BASE_BRANCH: ${{ github.base_ref }} - run: git merge-base --fork-point origin/$FORK_BASE_BRANCH + run: git merge-base --fork-point base/$FORK_BASE_BRANCH - name: Get changed files id: changed-files uses: tj-actions/changed-files@v18.6 From d1f6786c81558be0df6953b7cf2dd9cc2f04f6f6 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Tue, 5 Apr 2022 08:19:39 +0300 Subject: [PATCH 087/130] Try to remove variable in setting new origin Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 4 +--- .github/workflows/build-iroha1-fork.yml | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 7180e4a1fad..1bec722a564 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -29,10 +29,8 @@ jobs: - name: Set second remote - with: - url: ${{github.event.pull_request.base.repo.ssh_url}} run: | - git remote add base {{url}} + git remote add base {{github.event.pull_request.base.repo.ssh_url}} - name: Find common ancestor diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index fb850bb2de8..c0033fc8b46 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -23,10 +23,8 @@ jobs: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} - name: Set second remote - with: - url: ${{github.event.pull_request.base.repo.ssh_url}} run: | - git remote add base {{url}} + git remote add base {{github.event.pull_request.base.repo.ssh_url}} - name: Find common ancestor env: FORK_BASE_BRANCH: ${{ github.base_ref }} From d9995c54198c23ce8316eea3561b09c67f05580b Mon Sep 17 00:00:00 2001 From: safinsaf Date: Tue, 5 Apr 2022 08:50:11 +0300 Subject: [PATCH 088/130] Fix finding ancestor Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 17 ++++++++++------- .github/workflows/build-iroha1-fork.yml | 12 ++++++++---- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 1bec722a564..0d25867f86b 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -28,22 +28,25 @@ jobs: repository: ${{github.event.pull_request.head.repo.full_name}} - - name: Set second remote + name: Find common ancestor + id: ancestor run: | git remote add base {{github.event.pull_request.base.repo.ssh_url}} - - - - name: Find common ancestor + git fetch base + echo "::set-output ancestor_sha=ancestor_sha::$(git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH)" env: FORK_BASE_BRANCH: ${{ github.base_ref }} - run: git merge-base --fork-point base/$FORK_BASE_BRANCH - + FORK_HEAD_BRANCH: ${{ github.head_ref }} + outputs: + ancestor_sha: ${{steps.ancestor.outputs.ancestor_sha}} + + - name: Get changed files id: changed-files uses: tj-actions/changed-files@v18.6 with: - use_fork_point: True + base_sha: ${{ needs.ancestor.outputs.ancestor_sha }} - name: List all changed files diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index c0033fc8b46..3a0038af3d0 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -22,18 +22,22 @@ jobs: with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} - - name: Set second remote + - name: Find common ancestor + id: ancestor run: | git remote add base {{github.event.pull_request.base.repo.ssh_url}} - - name: Find common ancestor + git fetch base + echo "::set-output ancestor_sha=ancestor_sha::$(git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH)" env: FORK_BASE_BRANCH: ${{ github.base_ref }} - run: git merge-base --fork-point base/$FORK_BASE_BRANCH + FORK_HEAD_BRANCH: ${{ github.head_ref }} + outputs: + ancestor_sha: ${{steps.ancestor.outputs.ancestor_sha}} - name: Get changed files id: changed-files uses: tj-actions/changed-files@v18.6 with: - use_fork_point: True + base_sha: ${{ needs.ancestor.outputs.ancestor_sha }} - name: List all changed files run: | for file in ${{ steps.changed-files.outputs.all_changed_files }}; do From 68a11162d1907fd99a16b6f86d06a28773bcd502 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Tue, 5 Apr 2022 10:00:29 +0300 Subject: [PATCH 089/130] Fix output Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 7 +++---- .github/workflows/build-iroha1-fork.yml | 6 +++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 0d25867f86b..c3d4354321c 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -33,13 +33,12 @@ jobs: run: | git remote add base {{github.event.pull_request.base.repo.ssh_url}} git fetch base - echo "::set-output ancestor_sha=ancestor_sha::$(git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH)" + echo "::set-output name=ancestor_sha::$(git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH)" env: FORK_BASE_BRANCH: ${{ github.base_ref }} FORK_HEAD_BRANCH: ${{ github.head_ref }} - outputs: - ancestor_sha: ${{steps.ancestor.outputs.ancestor_sha}} - + # outputs: + # ancestor_sha: ${{steps.ancestor.outputs.ancestor_sha}} - name: Get changed files diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 3a0038af3d0..cd84d2a3409 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -27,12 +27,12 @@ jobs: run: | git remote add base {{github.event.pull_request.base.repo.ssh_url}} git fetch base - echo "::set-output ancestor_sha=ancestor_sha::$(git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH)" + echo "::set-output name=ancestor_sha::$(git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH)" env: FORK_BASE_BRANCH: ${{ github.base_ref }} FORK_HEAD_BRANCH: ${{ github.head_ref }} - outputs: - ancestor_sha: ${{steps.ancestor.outputs.ancestor_sha}} + # outputs: + # ancestor_sha: ${{steps.ancestor.outputs.ancestor_sha}} - name: Get changed files id: changed-files uses: tj-actions/changed-files@v18.6 From 8410f24cef81cf2a3b75958a26ec5070d58488c4 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Tue, 5 Apr 2022 10:10:25 +0300 Subject: [PATCH 090/130] Try fix base origin Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 2 +- .github/workflows/build-iroha1-fork.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index c3d4354321c..23f627a6cb0 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -31,7 +31,7 @@ jobs: name: Find common ancestor id: ancestor run: | - git remote add base {{github.event.pull_request.base.repo.ssh_url}} + git remote add base {{github.event.pull_request.base.repo.svn_url}} git fetch base echo "::set-output name=ancestor_sha::$(git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH)" env: diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index cd84d2a3409..9cd37d4ae4d 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -25,7 +25,7 @@ jobs: - name: Find common ancestor id: ancestor run: | - git remote add base {{github.event.pull_request.base.repo.ssh_url}} + git remote add base {{github.event.pull_request.base.repo.svn_url}} git fetch base echo "::set-output name=ancestor_sha::$(git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH)" env: From c48a6e2b2ec04d11ae89cac20a7c6183dba53fd8 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Tue, 5 Apr 2022 10:14:00 +0300 Subject: [PATCH 091/130] Try fix base origin Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 2 +- .github/workflows/build-iroha1-fork.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 23f627a6cb0..674a17f2fea 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -31,7 +31,7 @@ jobs: name: Find common ancestor id: ancestor run: | - git remote add base {{github.event.pull_request.base.repo.svn_url}} + git remote add base ${{github.event.pull_request.base.repo.ssh_url}} git fetch base echo "::set-output name=ancestor_sha::$(git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH)" env: diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 9cd37d4ae4d..aea5bc9c3df 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -25,7 +25,7 @@ jobs: - name: Find common ancestor id: ancestor run: | - git remote add base {{github.event.pull_request.base.repo.svn_url}} + git remote add base ${{github.event.pull_request.base.repo.ssh_url}} git fetch base echo "::set-output name=ancestor_sha::$(git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH)" env: From c9f76253df2893a83d518b7cf366b019d5d5461b Mon Sep 17 00:00:00 2001 From: safinsaf Date: Tue, 5 Apr 2022 10:17:22 +0300 Subject: [PATCH 092/130] Try fix base origin Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 2 +- .github/workflows/build-iroha1-fork.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 674a17f2fea..23f627a6cb0 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -31,7 +31,7 @@ jobs: name: Find common ancestor id: ancestor run: | - git remote add base ${{github.event.pull_request.base.repo.ssh_url}} + git remote add base {{github.event.pull_request.base.repo.svn_url}} git fetch base echo "::set-output name=ancestor_sha::$(git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH)" env: diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index aea5bc9c3df..9cd37d4ae4d 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -25,7 +25,7 @@ jobs: - name: Find common ancestor id: ancestor run: | - git remote add base ${{github.event.pull_request.base.repo.ssh_url}} + git remote add base {{github.event.pull_request.base.repo.svn_url}} git fetch base echo "::set-output name=ancestor_sha::$(git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH)" env: From d5a5f9c0611621ff3eec138ae82e3cba63bb0295 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Tue, 5 Apr 2022 10:19:22 +0300 Subject: [PATCH 093/130] Try fix base origin Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 2 +- .github/workflows/build-iroha1-fork.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 23f627a6cb0..6f504bd5dbf 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -31,7 +31,7 @@ jobs: name: Find common ancestor id: ancestor run: | - git remote add base {{github.event.pull_request.base.repo.svn_url}} + git remote add base ${{github.event.pull_request.base.repo.svn_url}} git fetch base echo "::set-output name=ancestor_sha::$(git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH)" env: diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 9cd37d4ae4d..bc3efbfc060 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -25,7 +25,7 @@ jobs: - name: Find common ancestor id: ancestor run: | - git remote add base {{github.event.pull_request.base.repo.svn_url}} + git remote add base ${{github.event.pull_request.base.repo.svn_url}} git fetch base echo "::set-output name=ancestor_sha::$(git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH)" env: From 0633c29db595577498abed4d52d930ba22285c9f Mon Sep 17 00:00:00 2001 From: safinsaf Date: Tue, 5 Apr 2022 10:31:34 +0300 Subject: [PATCH 094/130] Try fix base origin Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 3 ++- .github/workflows/build-iroha1-fork.yml | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 6f504bd5dbf..8fea9420634 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -33,7 +33,8 @@ jobs: run: | git remote add base ${{github.event.pull_request.base.repo.svn_url}} git fetch base - echo "::set-output name=ancestor_sha::$(git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH)" + git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH + echo "::set-output name=ancestor_sha::$(!!)" env: FORK_BASE_BRANCH: ${{ github.base_ref }} FORK_HEAD_BRANCH: ${{ github.head_ref }} diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index bc3efbfc060..6560c900fc4 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -27,7 +27,8 @@ jobs: run: | git remote add base ${{github.event.pull_request.base.repo.svn_url}} git fetch base - echo "::set-output name=ancestor_sha::$(git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH)" + git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH + echo "::set-output name=ancestor_sha::$(!!)" env: FORK_BASE_BRANCH: ${{ github.base_ref }} FORK_HEAD_BRANCH: ${{ github.head_ref }} From 0bd6133128bb9ef33a26cbc1aca0dd703b1f4d1f Mon Sep 17 00:00:00 2001 From: safinsaf Date: Tue, 5 Apr 2022 11:07:30 +0300 Subject: [PATCH 095/130] Try fix base origin Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 8fea9420634..f54e2e93b8d 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -33,8 +33,9 @@ jobs: run: | git remote add base ${{github.event.pull_request.base.repo.svn_url}} git fetch base - git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH - echo "::set-output name=ancestor_sha::$(!!)" + export COMMAND="git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH" + #echo "git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH" | sh + echo "::set-output name=ancestor_sha::$(echo $COMMAND | sh)" env: FORK_BASE_BRANCH: ${{ github.base_ref }} FORK_HEAD_BRANCH: ${{ github.head_ref }} From 77dd37ca66190f2c0534acfc8bd36f0cbac99440 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 08:40:32 +0300 Subject: [PATCH 096/130] Use export for setting output Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 1 - .github/workflows/build-iroha1-fork.yml | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index f54e2e93b8d..a341f5f9200 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -34,7 +34,6 @@ jobs: git remote add base ${{github.event.pull_request.base.repo.svn_url}} git fetch base export COMMAND="git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH" - #echo "git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH" | sh echo "::set-output name=ancestor_sha::$(echo $COMMAND | sh)" env: FORK_BASE_BRANCH: ${{ github.base_ref }} diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 6560c900fc4..ccbf836ae6a 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -27,8 +27,8 @@ jobs: run: | git remote add base ${{github.event.pull_request.base.repo.svn_url}} git fetch base - git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH - echo "::set-output name=ancestor_sha::$(!!)" + export COMMAND="git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH" + echo "::set-output name=ancestor_sha::$(echo $COMMAND | sh)" env: FORK_BASE_BRANCH: ${{ github.base_ref }} FORK_HEAD_BRANCH: ${{ github.head_ref }} From 9d453586dfbcb2f41d1916df476cc662e0994818 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 08:48:58 +0300 Subject: [PATCH 097/130] Try saving to file Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 4 ++-- .github/workflows/build-iroha1-fork.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index a341f5f9200..21aedd79f47 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -33,8 +33,8 @@ jobs: run: | git remote add base ${{github.event.pull_request.base.repo.svn_url}} git fetch base - export COMMAND="git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH" - echo "::set-output name=ancestor_sha::$(echo $COMMAND | sh)" + echo "git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH" > command.sh + echo "::set-output name=ancestor_sha::$(sh command.sh)" env: FORK_BASE_BRANCH: ${{ github.base_ref }} FORK_HEAD_BRANCH: ${{ github.head_ref }} diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index ccbf836ae6a..4b3ddf29b7d 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -27,8 +27,8 @@ jobs: run: | git remote add base ${{github.event.pull_request.base.repo.svn_url}} git fetch base - export COMMAND="git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH" - echo "::set-output name=ancestor_sha::$(echo $COMMAND | sh)" + echo "git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH" > command.sh + echo "::set-output name=ancestor_sha::$(sh command.sh)" env: FORK_BASE_BRANCH: ${{ github.base_ref }} FORK_HEAD_BRANCH: ${{ github.head_ref }} From 438637635906d58d14bb00d13b77432c8f66cf9f Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 08:53:04 +0300 Subject: [PATCH 098/130] Try saving to file Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 3 ++- .github/workflows/build-iroha1-fork.yml | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 21aedd79f47..54d5edb161e 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -34,7 +34,8 @@ jobs: git remote add base ${{github.event.pull_request.base.repo.svn_url}} git fetch base echo "git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH" > command.sh - echo "::set-output name=ancestor_sha::$(sh command.sh)" + cat command.sh + echo "::set-output name=ancestor_sha::$(cat command.sh | sh)" env: FORK_BASE_BRANCH: ${{ github.base_ref }} FORK_HEAD_BRANCH: ${{ github.head_ref }} diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 4b3ddf29b7d..f8b8516efba 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -28,7 +28,8 @@ jobs: git remote add base ${{github.event.pull_request.base.repo.svn_url}} git fetch base echo "git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH" > command.sh - echo "::set-output name=ancestor_sha::$(sh command.sh)" + cat command.sh + echo "::set-output name=ancestor_sha::$(cat command.sh | sh)" env: FORK_BASE_BRANCH: ${{ github.base_ref }} FORK_HEAD_BRANCH: ${{ github.head_ref }} From 69370978ad59a2d9a1a746c90182e5e569606f46 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 08:55:26 +0300 Subject: [PATCH 099/130] Try saving to file Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 2 +- .github/workflows/build-iroha1-fork.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 54d5edb161e..773d57deede 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -35,7 +35,7 @@ jobs: git fetch base echo "git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH" > command.sh cat command.sh - echo "::set-output name=ancestor_sha::$(cat command.sh | sh)" + echo "::set-output name=ancestor_sha::$(cat command.sh)" env: FORK_BASE_BRANCH: ${{ github.base_ref }} FORK_HEAD_BRANCH: ${{ github.head_ref }} diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index f8b8516efba..27ba6fd3879 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -29,7 +29,7 @@ jobs: git fetch base echo "git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH" > command.sh cat command.sh - echo "::set-output name=ancestor_sha::$(cat command.sh | sh)" + echo "::set-output name=ancestor_sha::$(cat command.sh)" env: FORK_BASE_BRANCH: ${{ github.base_ref }} FORK_HEAD_BRANCH: ${{ github.head_ref }} From f4634472646026e3b2ccc66996821b7eb44b9398 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 09:00:31 +0300 Subject: [PATCH 100/130] Try saving to file Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 2 +- .github/workflows/build-iroha1-fork.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 773d57deede..d8801f474ac 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -33,7 +33,7 @@ jobs: run: | git remote add base ${{github.event.pull_request.base.repo.svn_url}} git fetch base - echo "git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH" > command.sh + git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH > command.sh cat command.sh echo "::set-output name=ancestor_sha::$(cat command.sh)" env: diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 27ba6fd3879..d99a38659ef 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -27,7 +27,7 @@ jobs: run: | git remote add base ${{github.event.pull_request.base.repo.svn_url}} git fetch base - echo "git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH" > command.sh + git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH > command.sh cat command.sh echo "::set-output name=ancestor_sha::$(cat command.sh)" env: From 0a468802330fa3ea94f4be949486c33f1e9d78fb Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 09:02:42 +0300 Subject: [PATCH 101/130] Try saving to file Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 2 +- .github/workflows/build-iroha1-fork.yml | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index d8801f474ac..0627c0a7ae2 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -35,7 +35,7 @@ jobs: git fetch base git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH > command.sh cat command.sh - echo "::set-output name=ancestor_sha::$(cat command.sh)" + env: FORK_BASE_BRANCH: ${{ github.base_ref }} FORK_HEAD_BRANCH: ${{ github.head_ref }} diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index d99a38659ef..9efbcfcd8f0 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -29,7 +29,6 @@ jobs: git fetch base git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH > command.sh cat command.sh - echo "::set-output name=ancestor_sha::$(cat command.sh)" env: FORK_BASE_BRANCH: ${{ github.base_ref }} FORK_HEAD_BRANCH: ${{ github.head_ref }} From 048fc521224eb423389dbd00aaac750bec57bdc1 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 09:06:06 +0300 Subject: [PATCH 102/130] Try saving to file Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 3 +-- .github/workflows/build-iroha1-fork.yml | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 0627c0a7ae2..980cc266e2f 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -34,8 +34,7 @@ jobs: git remote add base ${{github.event.pull_request.base.repo.svn_url}} git fetch base git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH > command.sh - cat command.sh - + env: FORK_BASE_BRANCH: ${{ github.base_ref }} FORK_HEAD_BRANCH: ${{ github.head_ref }} diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 9efbcfcd8f0..68f6a7fb275 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -28,7 +28,6 @@ jobs: git remote add base ${{github.event.pull_request.base.repo.svn_url}} git fetch base git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH > command.sh - cat command.sh env: FORK_BASE_BRANCH: ${{ github.base_ref }} FORK_HEAD_BRANCH: ${{ github.head_ref }} From 2f731c1f2e1548f1eed1c480b848a34436c2541b Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 09:24:00 +0300 Subject: [PATCH 103/130] Debug using hardcoded values Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 2 +- .github/workflows/build-iroha1-fork.yml | 2 +- command.sh | 0 3 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 command.sh diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 980cc266e2f..7daa36bff10 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -33,7 +33,7 @@ jobs: run: | git remote add base ${{github.event.pull_request.base.repo.svn_url}} git fetch base - git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH > command.sh + git merge-base base/feature/DOPS-1651/enable-fork-build origin/main env: FORK_BASE_BRANCH: ${{ github.base_ref }} diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 68f6a7fb275..9c3468a0bd1 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -27,7 +27,7 @@ jobs: run: | git remote add base ${{github.event.pull_request.base.repo.svn_url}} git fetch base - git merge-base base/$FORK_BASE_BRANCH origin/$FORK_HEAD_BRANCH > command.sh + git merge-base base/feature/DOPS-1651/enable-fork-build origin/main env: FORK_BASE_BRANCH: ${{ github.base_ref }} FORK_HEAD_BRANCH: ${{ github.head_ref }} diff --git a/command.sh b/command.sh new file mode 100644 index 00000000000..e69de29bb2d From 634d3dfe829d1bfa90fdf4b4cde45d475379b948 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 09:27:05 +0300 Subject: [PATCH 104/130] Debug using hardcoded values Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 1 + .github/workflows/build-iroha1-fork.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 7daa36bff10..400352797a0 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -32,6 +32,7 @@ jobs: id: ancestor run: | git remote add base ${{github.event.pull_request.base.repo.svn_url}} + git remote add origin ${{github.event.pull_request.head.repo.svn_url}} git fetch base git merge-base base/feature/DOPS-1651/enable-fork-build origin/main diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 9c3468a0bd1..107ca28373d 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -26,6 +26,7 @@ jobs: id: ancestor run: | git remote add base ${{github.event.pull_request.base.repo.svn_url}} + git remote add origin ${{github.event.pull_request.head.repo.svn_url}} git fetch base git merge-base base/feature/DOPS-1651/enable-fork-build origin/main env: From 2d77772b11a7e40888dcb49d715d7e8d36eca2ce Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 09:28:31 +0300 Subject: [PATCH 105/130] Debug using hardcoded values Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 12 ++++++------ .github/workflows/build-iroha1-fork.yml | 11 ++++++----- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 400352797a0..10ecefc142a 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -20,12 +20,12 @@ jobs: run: | true - - - name: Checkout head - uses: actions/checkout@v3 - with: - ref: ${{github.event.pull_request.head.ref}} - repository: ${{github.event.pull_request.head.repo.full_name}} + # - + # name: Checkout head + # uses: actions/checkout@v3 + # with: + # ref: ${{github.event.pull_request.head.ref}} + # repository: ${{github.event.pull_request.head.repo.full_name}} - name: Find common ancestor diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 107ca28373d..1453eee77a0 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -17,11 +17,12 @@ jobs: steps: - run: | true - - name: Checkout head - uses: actions/checkout@v3 - with: - ref: ${{github.event.pull_request.head.ref}} - repository: ${{github.event.pull_request.head.repo.full_name}} + # - + # name: Checkout head + # uses: actions/checkout@v3 + # with: + # ref: ${{github.event.pull_request.head.ref}} + # repository: ${{github.event.pull_request.head.repo.full_name}} - name: Find common ancestor id: ancestor run: | From 285d2b505b4d1c6a2389c6832ebfc5e4e6982b11 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 09:30:50 +0300 Subject: [PATCH 106/130] Debug using hardcoded values Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 16 ++++++++-------- .github/workflows/build-iroha1-fork.yml | 15 +++++++-------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 10ecefc142a..f3b712da954 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -20,21 +20,21 @@ jobs: run: | true - # - - # name: Checkout head - # uses: actions/checkout@v3 - # with: - # ref: ${{github.event.pull_request.head.ref}} - # repository: ${{github.event.pull_request.head.repo.full_name}} + - + name: Checkout head + uses: actions/checkout@v3 + with: + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} - name: Find common ancestor id: ancestor run: | git remote add base ${{github.event.pull_request.base.repo.svn_url}} - git remote add origin ${{github.event.pull_request.head.repo.svn_url}} + git remote add head ${{github.event.pull_request.head.repo.svn_url}} git fetch base - git merge-base base/feature/DOPS-1651/enable-fork-build origin/main + git merge-base base/feature/DOPS-1651/enable-fork-build head/main env: FORK_BASE_BRANCH: ${{ github.base_ref }} diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 1453eee77a0..cf1038d97fa 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -17,19 +17,18 @@ jobs: steps: - run: | true - # - - # name: Checkout head - # uses: actions/checkout@v3 - # with: - # ref: ${{github.event.pull_request.head.ref}} - # repository: ${{github.event.pull_request.head.repo.full_name}} + - name: Checkout head + uses: actions/checkout@v3 + with: + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} - name: Find common ancestor id: ancestor run: | git remote add base ${{github.event.pull_request.base.repo.svn_url}} - git remote add origin ${{github.event.pull_request.head.repo.svn_url}} + git remote add head ${{github.event.pull_request.head.repo.svn_url}} git fetch base - git merge-base base/feature/DOPS-1651/enable-fork-build origin/main + git merge-base base/feature/DOPS-1651/enable-fork-build head/main env: FORK_BASE_BRANCH: ${{ github.base_ref }} FORK_HEAD_BRANCH: ${{ github.head_ref }} From d1f5c4ced5d37690822879293ac1a04d1ef0141d Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 09:35:25 +0300 Subject: [PATCH 107/130] Debug using hardcoded values Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 1 + .github/workflows/build-iroha1-fork.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index f3b712da954..2825a07e6f3 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -34,6 +34,7 @@ jobs: git remote add base ${{github.event.pull_request.base.repo.svn_url}} git remote add head ${{github.event.pull_request.head.repo.svn_url}} git fetch base + git fetch head git merge-base base/feature/DOPS-1651/enable-fork-build head/main env: diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index cf1038d97fa..899624a3ea5 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -28,6 +28,7 @@ jobs: git remote add base ${{github.event.pull_request.base.repo.svn_url}} git remote add head ${{github.event.pull_request.head.repo.svn_url}} git fetch base + git fetch head git merge-base base/feature/DOPS-1651/enable-fork-build head/main env: FORK_BASE_BRANCH: ${{ github.base_ref }} From b41d0c147c1dce838b36fdf6fba92644b81d2860 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 09:41:24 +0300 Subject: [PATCH 108/130] Try other action Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 55 ++++++++++++++----------- .github/workflows/build-iroha1-fork.yml | 51 ++++++++++++++--------- 2 files changed, 62 insertions(+), 44 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 2825a07e6f3..ec18188f276 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -27,36 +27,43 @@ jobs: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} - - - name: Find common ancestor - id: ancestor - run: | - git remote add base ${{github.event.pull_request.base.repo.svn_url}} - git remote add head ${{github.event.pull_request.head.repo.svn_url}} - git fetch base - git fetch head - git merge-base base/feature/DOPS-1651/enable-fork-build head/main + # - + # name: Find common ancestor + # id: ancestor + # run: | + # git remote add base ${{github.event.pull_request.base.repo.svn_url}} + # git remote add head ${{github.event.pull_request.head.repo.svn_url}} + # git fetch base + # git fetch head + # git merge-base base/feature/DOPS-1651/enable-fork-build head/main - env: - FORK_BASE_BRANCH: ${{ github.base_ref }} - FORK_HEAD_BRANCH: ${{ github.head_ref }} + # env: + # FORK_BASE_BRANCH: ${{ github.base_ref }} + # FORK_HEAD_BRANCH: ${{ github.head_ref }} # outputs: # ancestor_sha: ${{steps.ancestor.outputs.ancestor_sha}} - - - name: Get changed files - id: changed-files - uses: tj-actions/changed-files@v18.6 - with: - base_sha: ${{ needs.ancestor.outputs.ancestor_sha }} - - - - name: List all changed files - run: | - for file in ${{ steps.changed-files.outputs.all_changed_files }}; do - echo "$file was changed" + - id: files + uses: jitterbit/get-changed-files@v1 + - run: | + for changed_file in ${{ steps.files.outputs.all }}; do + echo "Do something with this ${changed_file}." done + # - + # name: Get changed files + # id: changed-files + # uses: tj-actions/changed-files@v18.6 + # with: + # base_sha: ${{ needs.ancestor.outputs.ancestor_sha }} + + # - + # name: List all changed files + # run: | + # for file in ${{ steps.changed-files.outputs.all_changed_files }}; do + # echo "$file was changed" + # done + ## GitHub Actions Workflow does not support yaml anchors ## and that is why there is a workaround with make-workflows.sh ## You should `pre-commit install` or use `pre-commit-hook.sh`, diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 899624a3ea5..2e36de757ac 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -22,29 +22,40 @@ jobs: with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} - - name: Find common ancestor - id: ancestor - run: | - git remote add base ${{github.event.pull_request.base.repo.svn_url}} - git remote add head ${{github.event.pull_request.head.repo.svn_url}} - git fetch base - git fetch head - git merge-base base/feature/DOPS-1651/enable-fork-build head/main - env: - FORK_BASE_BRANCH: ${{ github.base_ref }} - FORK_HEAD_BRANCH: ${{ github.head_ref }} + # - + # name: Find common ancestor + # id: ancestor + # run: | + # git remote add base ${{github.event.pull_request.base.repo.svn_url}} + # git remote add head ${{github.event.pull_request.head.repo.svn_url}} + # git fetch base + # git fetch head + # git merge-base base/feature/DOPS-1651/enable-fork-build head/main + + # env: + # FORK_BASE_BRANCH: ${{ github.base_ref }} + # FORK_HEAD_BRANCH: ${{ github.head_ref }} # outputs: # ancestor_sha: ${{steps.ancestor.outputs.ancestor_sha}} - - name: Get changed files - id: changed-files - uses: tj-actions/changed-files@v18.6 - with: - base_sha: ${{ needs.ancestor.outputs.ancestor_sha }} - - name: List all changed files - run: | - for file in ${{ steps.changed-files.outputs.all_changed_files }}; do - echo "$file was changed" + - id: files + uses: jitterbit/get-changed-files@v1 + - run: | + for changed_file in ${{ steps.files.outputs.all }}; do + echo "Do something with this ${changed_file}." done + # - + # name: Get changed files + # id: changed-files + # uses: tj-actions/changed-files@v18.6 + # with: + # base_sha: ${{ needs.ancestor.outputs.ancestor_sha }} + + # - + # name: List all changed files + # run: | + # for file in ${{ steps.changed-files.outputs.all_changed_files }}; do + # echo "$file was changed" + # done ## GitHub Actions Workflow does not support yaml anchors ## and that is why there is a workaround with make-workflows.sh ## You should `pre-commit install` or use `pre-commit-hook.sh`, From 720570a85f5a48858f44a5070f8bb789e9d66d67 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 09:49:27 +0300 Subject: [PATCH 109/130] Try other action Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 17 ++++++++---- .github/workflows/build-iroha1-fork.yml | 37 +++++++++++++------------ 2 files changed, 30 insertions(+), 24 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index ec18188f276..5d4a9343f76 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -43,12 +43,17 @@ jobs: # outputs: # ancestor_sha: ${{steps.ancestor.outputs.ancestor_sha}} - - id: files - uses: jitterbit/get-changed-files@v1 - - run: | - for changed_file in ${{ steps.files.outputs.all }}; do - echo "Do something with this ${changed_file}." - done + - + name: Filter files + uses: dorny/paths-filter@v2 + id: filter + + - + name: backend tests + run: + echo "$files" + with: + files: ${{ steps.filter.outputs.changed_files }} # - # name: Get changed files diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 2e36de757ac..fe6116344d8 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -37,25 +37,26 @@ jobs: # FORK_HEAD_BRANCH: ${{ github.head_ref }} # outputs: # ancestor_sha: ${{steps.ancestor.outputs.ancestor_sha}} - - id: files - uses: jitterbit/get-changed-files@v1 - - run: | - for changed_file in ${{ steps.files.outputs.all }}; do - echo "Do something with this ${changed_file}." - done - # - - # name: Get changed files - # id: changed-files - # uses: tj-actions/changed-files@v18.6 - # with: - # base_sha: ${{ needs.ancestor.outputs.ancestor_sha }} + - name: Filter files + uses: dorny/paths-filter@v2 + id: filter + - name: backend tests + run: echo "$files" + with: + files: ${{ steps.filter.outputs.changed_files }} + # - + # name: Get changed files + # id: changed-files + # uses: tj-actions/changed-files@v18.6 + # with: + # base_sha: ${{ needs.ancestor.outputs.ancestor_sha }} - # - - # name: List all changed files - # run: | - # for file in ${{ steps.changed-files.outputs.all_changed_files }}; do - # echo "$file was changed" - # done + # - + # name: List all changed files + # run: | + # for file in ${{ steps.changed-files.outputs.all_changed_files }}; do + # echo "$file was changed" + # done ## GitHub Actions Workflow does not support yaml anchors ## and that is why there is a workaround with make-workflows.sh ## You should `pre-commit install` or use `pre-commit-hook.sh`, From a830e0b3ee7b17a1ecc3fbd31345ddb76943ddc1 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 09:51:24 +0300 Subject: [PATCH 110/130] Try other action Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 6 +++--- .github/workflows/build-iroha1-fork.yml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 5d4a9343f76..57c2ce09c71 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -51,9 +51,9 @@ jobs: - name: backend tests run: - echo "$files" - with: - files: ${{ steps.filter.outputs.changed_files }} + echo "$changed_files" + env: + changed_files: ${{ steps.filter.outputs.changed_files }} # - # name: Get changed files diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index fe6116344d8..54715f9bdd6 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -41,9 +41,9 @@ jobs: uses: dorny/paths-filter@v2 id: filter - name: backend tests - run: echo "$files" - with: - files: ${{ steps.filter.outputs.changed_files }} + run: echo "$changed_files" + env: + changed_files: ${{ steps.filter.outputs.changed_files }} # - # name: Get changed files # id: changed-files From 7f6da4717871b4049b88cbd62b3d0780a0ed75e5 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 09:53:27 +0300 Subject: [PATCH 111/130] Try other action Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 4 ++++ .github/workflows/build-iroha1-fork.yml | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 57c2ce09c71..e669f3313ee 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -47,6 +47,10 @@ jobs: name: Filter files uses: dorny/paths-filter@v2 id: filter + with: + filters: | + github: + - '.github/**' - name: backend tests diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 54715f9bdd6..c1febb4b592 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -40,6 +40,10 @@ jobs: - name: Filter files uses: dorny/paths-filter@v2 id: filter + with: + filters: | + github: + - '.github/**' - name: backend tests run: echo "$changed_files" env: From 61438dc90bf754bc934229441b4314bf785c2664 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 09:58:28 +0300 Subject: [PATCH 112/130] Try other action Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 45 +++---------------------- .github/workflows/build-iroha1-fork.yml | 36 ++------------------ 2 files changed, 6 insertions(+), 75 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index e669f3313ee..6c291b407da 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -16,10 +16,7 @@ jobs: name: Pull requests from forks should use other workflow if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name }} steps: - - - run: | - true - + - name: Checkout head uses: actions/checkout@v3 @@ -27,22 +24,6 @@ jobs: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} - # - - # name: Find common ancestor - # id: ancestor - # run: | - # git remote add base ${{github.event.pull_request.base.repo.svn_url}} - # git remote add head ${{github.event.pull_request.head.repo.svn_url}} - # git fetch base - # git fetch head - # git merge-base base/feature/DOPS-1651/enable-fork-build head/main - - # env: - # FORK_BASE_BRANCH: ${{ github.base_ref }} - # FORK_HEAD_BRANCH: ${{ github.head_ref }} - # outputs: - # ancestor_sha: ${{steps.ancestor.outputs.ancestor_sha}} - - name: Filter files uses: dorny/paths-filter@v2 @@ -51,27 +32,9 @@ jobs: filters: | github: - '.github/**' - - - - name: backend tests - run: - echo "$changed_files" - env: - changed_files: ${{ steps.filter.outputs.changed_files }} - - # - - # name: Get changed files - # id: changed-files - # uses: tj-actions/changed-files@v18.6 - # with: - # base_sha: ${{ needs.ancestor.outputs.ancestor_sha }} - - # - - # name: List all changed files - # run: | - # for file in ${{ steps.changed-files.outputs.all_changed_files }}; do - # echo "$file was changed" - # done + dockerfile: + - '**/Dockerfile' + ## GitHub Actions Workflow does not support yaml anchors ## and that is why there is a workaround with make-workflows.sh diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index c1febb4b592..85e62edf0b2 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -15,28 +15,11 @@ jobs: name: Pull requests from forks should use other workflow if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name }} steps: - - run: | - true - name: Checkout head uses: actions/checkout@v3 with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} - # - - # name: Find common ancestor - # id: ancestor - # run: | - # git remote add base ${{github.event.pull_request.base.repo.svn_url}} - # git remote add head ${{github.event.pull_request.head.repo.svn_url}} - # git fetch base - # git fetch head - # git merge-base base/feature/DOPS-1651/enable-fork-build head/main - - # env: - # FORK_BASE_BRANCH: ${{ github.base_ref }} - # FORK_HEAD_BRANCH: ${{ github.head_ref }} - # outputs: - # ancestor_sha: ${{steps.ancestor.outputs.ancestor_sha}} - name: Filter files uses: dorny/paths-filter@v2 id: filter @@ -44,23 +27,8 @@ jobs: filters: | github: - '.github/**' - - name: backend tests - run: echo "$changed_files" - env: - changed_files: ${{ steps.filter.outputs.changed_files }} - # - - # name: Get changed files - # id: changed-files - # uses: tj-actions/changed-files@v18.6 - # with: - # base_sha: ${{ needs.ancestor.outputs.ancestor_sha }} - - # - - # name: List all changed files - # run: | - # for file in ${{ steps.changed-files.outputs.all_changed_files }}; do - # echo "$file was changed" - # done + dockerfile: + - '**/Dockerfile' ## GitHub Actions Workflow does not support yaml anchors ## and that is why there is a workaround with make-workflows.sh ## You should `pre-commit install` or use `pre-commit-hook.sh`, From 76f4794f75badfc696489ee2e1f0fd5720b5f1b3 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 10:08:12 +0300 Subject: [PATCH 113/130] Try other action Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 12 ++++++++++++ .github/workflows/build-iroha1-fork.yml | 10 ++++++++++ 2 files changed, 22 insertions(+) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 6c291b407da..368184de373 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -35,6 +35,18 @@ jobs: dockerfile: - '**/Dockerfile' + - name: verify .github folder is not changed + if: steps.filter.outputs.github == 'true' + run: | + echo "Pull requests from forks are not allowed to change .github folder" + false + + - name: verify Dockerfiles are not changed + if: steps.filter.outputs.dockerfile == 'true' + run: | + echo "Pull requests from forks are not allowed to change Dockerfiles" + false + ## GitHub Actions Workflow does not support yaml anchors ## and that is why there is a workaround with make-workflows.sh diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 85e62edf0b2..a4d1f0ef6f3 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -29,6 +29,16 @@ jobs: - '.github/**' dockerfile: - '**/Dockerfile' + - name: verify .github folder is not changed + if: steps.filter.outputs.github == 'true' + run: | + echo "Pull requests from forks are not allowed to change .github folder" + false + - name: verify Dockerfiles are not changed + if: steps.filter.outputs.dockerfile == 'true' + run: | + echo "Pull requests from forks are not allowed to change Dockerfiles" + false ## GitHub Actions Workflow does not support yaml anchors ## and that is why there is a workaround with make-workflows.sh ## You should `pre-commit install` or use `pre-commit-hook.sh`, From b74c1fc7561461ee6cb1237908fab3cc15cbe326 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 10:37:34 +0300 Subject: [PATCH 114/130] Add comments, replace some anchors Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 24 ++++++++++-------------- .github/build-iroha1.src.yml | 11 ++++------- .github/workflows/build-iroha1-fork.yml | 5 +++-- .github/workflows/build-iroha1.yml | 11 +++-------- 4 files changed, 20 insertions(+), 31 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 368184de373..ea0064ec356 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -1,5 +1,7 @@ name: Iroha1-fork +## This workflow is created for pull requests from forks only and has less permissions than build-iroha1 workflow + on: pull_request_target: branches: [ main, support/1.*, edge, develop, feature/DOPS-1651/enable-fork-build ] ## target branches @@ -9,21 +11,21 @@ env: jobs: - ## This workflow is created for pull requests from forks only and has less permissions + ## This step allows to skip the workflow completely for pull_requests from the same repo + ## Also it checks that that .github folder and Dockerfiles are not changed check_if_pull_request_comes_from_fork: runs-on: ubuntu-20.04 #ubuntu-latest name: Pull requests from forks should use other workflow if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name }} steps: - - - + + - &step_checkout_head name: Checkout head - uses: actions/checkout@v3 - with: + uses: actions/checkout@v2 + with: &step_checkout_with_head ref: ${{github.event.pull_request.head.ref}} - repository: ${{github.event.pull_request.head.repo.full_name}} - + repository: ${{github.event.pull_request.head.repo.full_name}} - name: Filter files uses: dorny/paths-filter@v2 @@ -47,7 +49,6 @@ jobs: echo "Pull requests from forks are not allowed to change Dockerfiles" false - ## GitHub Actions Workflow does not support yaml anchors ## and that is why there is a workaround with make-workflows.sh ## You should `pre-commit install` or use `pre-commit-hook.sh`, @@ -82,12 +83,7 @@ jobs: "PR_NUM="+(.number|tostring), "PR_REPO="+.head.repo.full_name' >>$GITHUB_ENV - *step_show_context - - &step_checkout_head - name: Checkout head - uses: actions/checkout@v2 - with: &step_checkout_with_head - ref: ${{github.event.pull_request.head.ref}} - repository: ${{github.event.pull_request.head.repo.full_name}} + - *step_checkout_head - run: sudo snap install yq - diff --git a/.github/build-iroha1.src.yml b/.github/build-iroha1.src.yml index ffe021c8d15..2d20a786e18 100644 --- a/.github/build-iroha1.src.yml +++ b/.github/build-iroha1.src.yml @@ -1,5 +1,9 @@ name: Iroha1 +## IMPORTANT +## This workflow is not run for forks, check build-iroha1-fork for pull_requests from forks + + ## TODO IMPORTANT DISALLOW deploying tags and main and develop builds where skip_testing was set. ## TODO 1. [vcpkg,optimization-space,optimization-speed] ## Build only Debug or only Release - reduce vcpkg build duration and output size 2times @@ -22,13 +26,7 @@ name: Iroha1 ## TODO [cmake,dockerimage,iroha-builder] To improve speed of vcpkg step install to iroha-builder ## docker image cmake 3.20.1 or later and ninja 1.10.1 or later. ## TODO actions/create-release for tags -## TODO use event pull_request_target to handle PRs from authorized forks, -## assert they do not change workflow.yml because it is not applied. -## CHEAT SHEET -## check if PR head repo is fork: ${{ github.event.pull_request.head.repo.fork }} -## check if PR is from other repo: ${{ github.event.pull_request.head.repo == github.event.pull_request.base.repo }} in this case secrets are empty -## ternary: ${{ fromJSON('["no", "yes"]')[github.ref != 'refs/heads/master'] }} ## PITFAILS ## * checkout issue on self-hosted runner with Docker, see https://github.com/actions/runner/issues/434 @@ -42,7 +40,6 @@ name: Iroha1 ## * AWS-hosted runners could respond slowly, it often takes about 1 minute or more to prepare runner, if it was not idling. ## * AWS-hosted runners has maximum active runners quote, ask @bulat5 or @Sofiane_bnh to increase if required. ## * Our AWS-hosted runners are shared with Iroha2 -## * Secrets are inaccessable for PRs from public forks. GH-token is read-only. No way to push dockerimages when PR is from fork. ## * Docker containers must run as root, see checkout issue https://github.com/actions/runner/issues/434 ## TODO make these different workflows - reduce number of conditionals inside jobs like 'step_detect_commented_pr' diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index a4d1f0ef6f3..5119b5f0a41 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -2,21 +2,22 @@ ## Generated from build-iroha1-fork.src.yml with make-workflows.sh name: Iroha1-fork +## This workflow is created for pull requests from forks only and has less permissions than build-iroha1 workflow on: pull_request_target: branches: [main, support/1.*, edge, develop, feature/DOPS-1651/enable-fork-build] ## target branches env: DOCKERHUB_ORG: hyperledger jobs: - ## This workflow is created for pull requests from forks only and has less permissions ## This step allows to skip the workflow completely for pull_requests from the same repo + ## Also it checks that that .github folder and Dockerfiles are not changed check_if_pull_request_comes_from_fork: runs-on: ubuntu-20.04 #ubuntu-latest name: Pull requests from forks should use other workflow if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name }} steps: - name: Checkout head - uses: actions/checkout@v3 + uses: actions/checkout@v2 with: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} diff --git a/.github/workflows/build-iroha1.yml b/.github/workflows/build-iroha1.yml index b5c29e7a56a..b3d6aeea387 100644 --- a/.github/workflows/build-iroha1.yml +++ b/.github/workflows/build-iroha1.yml @@ -2,6 +2,9 @@ ## Generated from build-iroha1.src.yml with make-workflows.sh name: Iroha1 +## IMPORTANT +## This workflow is not run for forks, check build-iroha1-fork for pull_requests from forks + ## TODO IMPORTANT DISALLOW deploying tags and main and develop builds where skip_testing was set. ## TODO 1. [vcpkg,optimization-space,optimization-speed] ## Build only Debug or only Release - reduce vcpkg build duration and output size 2times @@ -24,13 +27,6 @@ name: Iroha1 ## TODO [cmake,dockerimage,iroha-builder] To improve speed of vcpkg step install to iroha-builder ## docker image cmake 3.20.1 or later and ninja 1.10.1 or later. ## TODO actions/create-release for tags -## TODO use event pull_request_target to handle PRs from authorized forks, -## assert they do not change workflow.yml because it is not applied. - -## CHEAT SHEET -## check if PR head repo is fork: ${{ github.event.pull_request.head.repo.fork }} -## check if PR is from other repo: ${{ github.event.pull_request.head.repo == github.event.pull_request.base.repo }} in this case secrets are empty -## ternary: ${{ fromJSON('["no", "yes"]')[github.ref != 'refs/heads/master'] }} ## PITFAILS ## * checkout issue on self-hosted runner with Docker, see https://github.com/actions/runner/issues/434 @@ -44,7 +40,6 @@ name: Iroha1 ## * AWS-hosted runners could respond slowly, it often takes about 1 minute or more to prepare runner, if it was not idling. ## * AWS-hosted runners has maximum active runners quote, ask @bulat5 or @Sofiane_bnh to increase if required. ## * Our AWS-hosted runners are shared with Iroha2 -## * Secrets are inaccessable for PRs from public forks. GH-token is read-only. No way to push dockerimages when PR is from fork. ## * Docker containers must run as root, see checkout issue https://github.com/actions/runner/issues/434 ## TODO make these different workflows - reduce number of conditionals inside jobs like 'step_detect_commented_pr' From bd8a070bf5ca71e10796d55d5731fe4cdd0d04d3 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 10:52:15 +0300 Subject: [PATCH 115/130] Remove non-needed job Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 49 +++----------- .github/workflows/build-iroha1-fork.yml | 88 +------------------------ 2 files changed, 12 insertions(+), 125 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index ea0064ec356..2337acecdba 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -49,14 +49,14 @@ jobs: echo "Pull requests from forks are not allowed to change Dockerfiles" false - ## GitHub Actions Workflow does not support yaml anchors - ## and that is why there is a workaround with make-workflows.sh - ## You should `pre-commit install` or use `pre-commit-hook.sh`, - ## anyway please read .github/README.md - check_workflow_yaml_coressponds_to_src_yaml: + + generate_matrixes: runs-on: ubuntu-20.04 #ubuntu-latest - name: Check if github workflows were properly made from sources needs: check_if_pull_request_comes_from_fork + #container: ubuntu:latest + if: ${{ (github.event_name != 'comment') || ( github.event.comment && + github.event.issue.pull_request && + startsWith(github.event.comment.body, '/build') ) }} steps: - &step_show_context name: Show context @@ -82,27 +82,6 @@ jobs: "PR_SHA="+.head.sha, "PR_NUM="+(.number|tostring), "PR_REPO="+.head.repo.full_name' >>$GITHUB_ENV - - *step_show_context - - *step_checkout_head - - - run: sudo snap install yq - - - name: Check if .github/workflows/*.yml correspond to *.src.yml - run: | - set -x - [[ $(./.github/make-workflows.sh -x --worktree) = *"everything is up to date" ]] - - - generate_matrixes: - runs-on: ubuntu-20.04 #ubuntu-latest - needs: check_if_pull_request_comes_from_fork - #container: ubuntu:latest - if: ${{ (github.event_name != 'comment') || ( github.event.comment && - github.event.issue.pull_request && - startsWith(github.event.comment.body, '/build') ) }} - steps: - - *step_show_context - - *step_detect_commented_pr - *step_checkout_head - name: Generate matrix for build triggered by chat-ops - comment to PR @@ -184,7 +163,7 @@ jobs: matrix_dockerimage_debug: ${{steps.matrixes.outputs.matrix_dockerimage_debug}} Docker-iroha-builder: - needs: check_workflow_yaml_coressponds_to_src_yaml + needs: check_if_pull_request_comes_from_fork runs-on: ubuntu-20.04 #ubuntu-latest #[ self-hosted, Linux ] steps: - *step_show_context @@ -292,9 +271,6 @@ jobs: push: ${{ steps.docker_login.outcome == 'success' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - # env: - # DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - # DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} - &step_docker_build_and_push_ghcr <<: *step_docker_build_and_push id: build_and_push_ghcr @@ -304,9 +280,6 @@ jobs: push: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo == github.event.pull_request.base.repo }} tags: ${{ steps.meta_ghcr.outputs.tags }} labels: ${{ steps.meta_ghcr.outputs.labels }} - # env: - # DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - # DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} - &step_docker_move_cache # Temp fix # https://github.com/docker/build-push-action/issues/252 @@ -339,7 +312,6 @@ jobs: - Docker-iroha-builder - generate_matrixes runs-on: [ self-hosted, Linux ] - #runs-on: ubuntu-20.04 container: ## Container is taken from previous job image: &container_image ${{needs.Docker-iroha-builder.outputs.container}} options: --user root @@ -619,7 +591,7 @@ jobs: ## Just to align picture prepare-macos-env: - needs: check_workflow_yaml_coressponds_to_src_yaml + needs: check_if_pull_request_comes_from_fork runs-on: macos-latest steps: - *step_show_context @@ -687,7 +659,7 @@ jobs: ## Just to align picture prepare-windows-env: - needs: check_workflow_yaml_coressponds_to_src_yaml + needs: check_if_pull_request_comes_from_fork runs-on: windows-latest steps: - *step_show_context @@ -762,9 +734,6 @@ jobs: fail-fast: false matrix: ${{ fromJSON( needs.generate_matrixes.outputs.matrix_dockerimage_release ) }} if: ${{ fromJSON( needs.generate_matrixes.outputs.matrix_dockerimage_release ).include[0] }} - #env: &env_dockerhub_release - # <<: *env_dockerhub - # IMAGE_NAME: iroha env: IMAGE_NAME: iroha steps: diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 5119b5f0a41..47cbd332d18 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -40,58 +40,6 @@ jobs: run: | echo "Pull requests from forks are not allowed to change Dockerfiles" false - ## GitHub Actions Workflow does not support yaml anchors - ## and that is why there is a workaround with make-workflows.sh - ## You should `pre-commit install` or use `pre-commit-hook.sh`, - ## anyway please read .github/README.md - check_workflow_yaml_coressponds_to_src_yaml: - runs-on: ubuntu-20.04 #ubuntu-latest - name: Check if github workflows were properly made from sources - needs: check_if_pull_request_comes_from_fork - steps: - - name: Show context - run: | - echo "::group::GitHub context" - cat <<'END' - ${{ toJson(github) }} - END - echo "::endgroup::" - echo "::group::GitHub needs" - cat <<'END' - ${{ toJson(needs) }} - END - echo "::endgroup::" - - name: REF and SHA of commented PR to ENV - if: github.event.comment - run: > - curl -fsSL ${{github.event.issue.pull_request.url}} -H "Authorization: token ${{github.token}}" | jq -r ' - - "PR_REF="+.head.ref, - "PR_SHA="+.head.sha, - "PR_NUM="+(.number|tostring), - "PR_REPO="+.head.repo.full_name' >>$GITHUB_ENV - - name: Show context - run: | - echo "::group::GitHub context" - cat <<'END' - ${{ toJson(github) }} - END - echo "::endgroup::" - echo "::group::GitHub needs" - cat <<'END' - ${{ toJson(needs) }} - END - echo "::endgroup::" - - name: Checkout head - uses: actions/checkout@v2 - with: - ref: ${{github.event.pull_request.head.ref}} - repository: ${{github.event.pull_request.head.repo.full_name}} - - run: sudo snap install yq - - name: Check if .github/workflows/*.yml correspond to *.src.yml - run: | - set -x - [[ $(./.github/make-workflows.sh -x --worktree) = *"everything is up to date" ]] generate_matrixes: runs-on: ubuntu-20.04 #ubuntu-latest needs: check_if_pull_request_comes_from_fork @@ -198,7 +146,7 @@ jobs: matrix_dockerimage_release: ${{steps.matrixes.outputs.matrix_dockerimage_release}} matrix_dockerimage_debug: ${{steps.matrixes.outputs.matrix_dockerimage_debug}} Docker-iroha-builder: - needs: check_workflow_yaml_coressponds_to_src_yaml + needs: check_if_pull_request_comes_from_fork runs-on: ubuntu-20.04 #ubuntu-latest #[ self-hosted, Linux ] steps: - name: Show context @@ -325,9 +273,6 @@ jobs: push: ${{ steps.docker_login.outcome == 'success' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - # env: - # DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - # DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} - uses: docker/build-push-action@v2 id: build_and_push_ghcr name: Build and push to GHCR @@ -338,9 +283,6 @@ jobs: push: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo == github.event.pull_request.base.repo }} tags: ${{ steps.meta_ghcr.outputs.tags }} labels: ${{ steps.meta_ghcr.outputs.labels }} - # env: - # DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - # DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} - # Temp fix # https://github.com/docker/build-push-action/issues/252 # https://github.com/moby/buildkit/issues/1896 @@ -369,7 +311,6 @@ jobs: - Docker-iroha-builder - generate_matrixes runs-on: [self-hosted, Linux] - #runs-on: ubuntu-20.04 container: ## Container is taken from previous job image: ${{needs.Docker-iroha-builder.outputs.container}} options: --user root @@ -656,7 +597,6 @@ jobs: - Docker-iroha-builder - generate_matrixes runs-on: [self-hosted, Linux] - #runs-on: ubuntu-20.04 container: ## Container is taken from previous job image: ${{needs.Docker-iroha-builder.outputs.container}} options: --user root @@ -939,7 +879,7 @@ jobs: if: ${{ fromJSON( needs.generate_matrixes.outputs.matrix_ubuntu_release ).include[0] }} ## Just to align picture prepare-macos-env: - needs: check_workflow_yaml_coressponds_to_src_yaml + needs: check_if_pull_request_comes_from_fork runs-on: macos-latest steps: - name: Show context @@ -1238,7 +1178,7 @@ jobs: timeout-minutes: 70 ## Just to align picture prepare-windows-env: - needs: check_workflow_yaml_coressponds_to_src_yaml + needs: check_if_pull_request_comes_from_fork runs-on: windows-latest steps: - name: Show context @@ -1353,9 +1293,6 @@ jobs: fail-fast: false matrix: ${{ fromJSON( needs.generate_matrixes.outputs.matrix_dockerimage_release ) }} if: ${{ fromJSON( needs.generate_matrixes.outputs.matrix_dockerimage_release ).include[0] }} - #env: &env_dockerhub_release - # <<: *env_dockerhub - # IMAGE_NAME: iroha env: IMAGE_NAME: iroha steps: @@ -1508,10 +1445,6 @@ jobs: cache-to: type=local,dest=/tmp/.buildx-cache-new tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - # env: - # DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - # DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} - context: docker/release/ push: ${{ steps.docker_login.outcome == 'success' }} - uses: docker/build-push-action@v2 @@ -1523,10 +1456,6 @@ jobs: push: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo == github.event.pull_request.base.repo }} tags: ${{ steps.meta_ghcr.outputs.tags }} labels: ${{ steps.meta_ghcr.outputs.labels }} - # env: - # DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - # DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} - context: docker/release/ - # Temp fix # https://github.com/docker/build-push-action/issues/252 @@ -1537,9 +1466,6 @@ jobs: mv /tmp/.buildx-cache-new /tmp/.buildx-cache docker-D: runs-on: [self-hosted, Linux] #ubuntu-latest - #env: &env_dockerhub_release - # <<: *env_dockerhub - # IMAGE_NAME: iroha env: IMAGE_NAME: iroha steps: @@ -1692,10 +1618,6 @@ jobs: cache-to: type=local,dest=/tmp/.buildx-cache-new tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - # env: - # DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - # DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} - context: docker/release/ push: ${{ steps.docker_login.outcome == 'success' }} - uses: docker/build-push-action@v2 @@ -1707,10 +1629,6 @@ jobs: push: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo == github.event.pull_request.base.repo }} tags: ${{ steps.meta_ghcr.outputs.tags }} labels: ${{ steps.meta_ghcr.outputs.labels }} - # env: - # DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - # DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} - context: docker/release/ - # Temp fix # https://github.com/docker/build-push-action/issues/252 From 5b566a27281403c92b17ab35ee53be5bf6ebe1b0 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 11:14:56 +0300 Subject: [PATCH 116/130] Add permissions Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 13 ++++++++++++- .github/workflows/build-iroha1-fork.yml | 11 +++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 2337acecdba..d7984fbbcaf 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -1,7 +1,18 @@ name: Iroha1-fork -## This workflow is created for pull requests from forks only and has less permissions than build-iroha1 workflow +permissions: + actions: read + checks: read + contents: read + deployments: read + issues: read + packages: read + pull-requests: read + repository-projects: read + security-events: read + statuses: read +## This workflow is created for pull requests from forks only and has less permissions than build-iroha1 workflow on: pull_request_target: branches: [ main, support/1.*, edge, develop, feature/DOPS-1651/enable-fork-build ] ## target branches diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 47cbd332d18..fc795ad4ef9 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -2,6 +2,17 @@ ## Generated from build-iroha1-fork.src.yml with make-workflows.sh name: Iroha1-fork +permissions: + actions: read + checks: read + contents: read + deployments: read + issues: read + packages: read + pull-requests: read + repository-projects: read + security-events: read + statuses: read ## This workflow is created for pull requests from forks only and has less permissions than build-iroha1 workflow on: pull_request_target: From 6edad98e34c7eb458289699773ac2a36f1efd677 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 11:28:30 +0300 Subject: [PATCH 117/130] Fix permissions Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 4 ++-- .github/workflows/build-iroha1-fork.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index d7984fbbcaf..2886829d761 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -4,9 +4,9 @@ permissions: actions: read checks: read contents: read - deployments: read + deployments: write issues: read - packages: read + packages: write pull-requests: read repository-projects: read security-events: read diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index fc795ad4ef9..2e6c5fc577c 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -6,9 +6,9 @@ permissions: actions: read checks: read contents: read - deployments: read + deployments: write issues: read - packages: read + packages: write pull-requests: read repository-projects: read security-events: read From 50658612a4a210ef6891a87e95059e801c6f1761 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 11:37:47 +0300 Subject: [PATCH 118/130] Set none to deployments Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 2 +- .github/workflows/build-iroha1-fork.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 2886829d761..c4995a210d2 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -4,7 +4,7 @@ permissions: actions: read checks: read contents: read - deployments: write + deployments: none issues: read packages: write pull-requests: read diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 2e6c5fc577c..d676a472274 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -6,7 +6,7 @@ permissions: actions: read checks: read contents: read - deployments: write + deployments: none issues: read packages: write pull-requests: read From c47eb9df11b465918101b790a82a10696fbe158a Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 13:05:09 +0300 Subject: [PATCH 119/130] Update comments, remove odd steps Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 1 + .github/build-iroha1.src.yml | 6 ++---- .github/workflows/build-iroha1-fork.yml | 1 + .github/workflows/build-iroha1.yml | 4 +--- command.sh | 0 5 files changed, 5 insertions(+), 7 deletions(-) delete mode 100644 command.sh diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index c4995a210d2..9e663fe5a42 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -1,5 +1,6 @@ name: Iroha1-fork +# The only write permission requird is packages permissions: actions: read checks: read diff --git a/.github/build-iroha1.src.yml b/.github/build-iroha1.src.yml index 2d20a786e18..a3133098056 100644 --- a/.github/build-iroha1.src.yml +++ b/.github/build-iroha1.src.yml @@ -1,7 +1,7 @@ name: Iroha1 ## IMPORTANT -## This workflow is not run for forks, check build-iroha1-fork for pull_requests from forks +## This workflow does not run for forks, check build-iroha1-fork for pull requests from forks ## TODO IMPORTANT DISALLOW deploying tags and main and develop builds where skip_testing was set. @@ -105,9 +105,7 @@ jobs: ${{ toJson(needs) }} END echo "::endgroup::" - - - run: | - true + ## GitHub Actions Workflow does not support yaml anchors ## and that is why there is a workaround with make-workflows.sh diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index d676a472274..9332c742dc6 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -2,6 +2,7 @@ ## Generated from build-iroha1-fork.src.yml with make-workflows.sh name: Iroha1-fork +# The only write permission requird is packages permissions: actions: read checks: read diff --git a/.github/workflows/build-iroha1.yml b/.github/workflows/build-iroha1.yml index b3d6aeea387..9d0356c4d7f 100644 --- a/.github/workflows/build-iroha1.yml +++ b/.github/workflows/build-iroha1.yml @@ -3,7 +3,7 @@ name: Iroha1 ## IMPORTANT -## This workflow is not run for forks, check build-iroha1-fork for pull_requests from forks +## This workflow does not run for forks, check build-iroha1-fork for pull requests from forks ## TODO IMPORTANT DISALLOW deploying tags and main and develop builds where skip_testing was set. ## TODO 1. [vcpkg,optimization-space,optimization-speed] @@ -102,8 +102,6 @@ jobs: ${{ toJson(needs) }} END echo "::endgroup::" - - run: | - true ## GitHub Actions Workflow does not support yaml anchors ## and that is why there is a workaround with make-workflows.sh ## You should `pre-commit install` or use `pre-commit-hook.sh`, diff --git a/command.sh b/command.sh deleted file mode 100644 index e69de29bb2d..00000000000 From c654b70cea8e181c103b83e0b4a1b385cc4109f8 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 16:38:31 +0300 Subject: [PATCH 120/130] Not allow changing scripts used in dockerfile Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 4 +++- .github/workflows/build-iroha1-fork.yml | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 9e663fe5a42..23a8cab0cd7 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -48,6 +48,8 @@ jobs: - '.github/**' dockerfile: - '**/Dockerfile' + - 'docker/release/entrypoint.sh' + - 'docker/release/wait-for-it.sh' - name: verify .github folder is not changed if: steps.filter.outputs.github == 'true' @@ -738,7 +740,7 @@ jobs: docker-R: &job_docker_image_release needs: - build-UR - - generate_matrixes + - generate_matrixespackages: write runs-on: [ self-hosted, Linux ] #ubuntu-latest # strategy: *strategy_ubuntu_release # if: *if_ubuntu_release diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 9332c742dc6..ceb335e864b 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -42,6 +42,8 @@ jobs: - '.github/**' dockerfile: - '**/Dockerfile' + - 'docker/release/entrypoint.sh' + - 'docker/release/wait-for-it.sh' - name: verify .github folder is not changed if: steps.filter.outputs.github == 'true' run: | @@ -1297,7 +1299,7 @@ jobs: docker-R: needs: - build-UR - - generate_matrixes + - generate_matrixespackages: write runs-on: [self-hosted, Linux] #ubuntu-latest # strategy: *strategy_ubuntu_release # if: *if_ubuntu_release From 84ef6755d44f8f87b87849b0917498ac06d50844 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 16:57:29 +0300 Subject: [PATCH 121/130] Add new filters Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 8 ++++---- .github/workflows/build-iroha1-fork.yml | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 23a8cab0cd7..1353b70a554 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -45,11 +45,11 @@ jobs: with: filters: | github: - - '.github/**' + - ".github/**" dockerfile: - - '**/Dockerfile' - - 'docker/release/entrypoint.sh' - - 'docker/release/wait-for-it.sh' + - "**/Dockerfile" + - "docker/release/entrypoint.sh" + - "docker/release/wait-for-it.sh" - name: verify .github folder is not changed if: steps.filter.outputs.github == 'true' diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index ceb335e864b..2f2fcc658e5 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -39,11 +39,11 @@ jobs: with: filters: | github: - - '.github/**' + - ".github/**" dockerfile: - - '**/Dockerfile' - - 'docker/release/entrypoint.sh' - - 'docker/release/wait-for-it.sh' + - "**/Dockerfile" + - "docker/release/entrypoint.sh" + - "docker/release/wait-for-it.sh" - name: verify .github folder is not changed if: steps.filter.outputs.github == 'true' run: | From b35c99ea4558e32e5acedc198b2b7bdbfbdc2d7c Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 16:58:25 +0300 Subject: [PATCH 122/130] Debug new filters Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 2 +- .github/workflows/build-iroha1-fork.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 1353b70a554..2d84ade6392 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -49,7 +49,7 @@ jobs: dockerfile: - "**/Dockerfile" - "docker/release/entrypoint.sh" - - "docker/release/wait-for-it.sh" + # - "docker/release/wait-for-it.sh" - name: verify .github folder is not changed if: steps.filter.outputs.github == 'true' diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 2f2fcc658e5..002ecf3eec2 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -43,7 +43,7 @@ jobs: dockerfile: - "**/Dockerfile" - "docker/release/entrypoint.sh" - - "docker/release/wait-for-it.sh" + # - "docker/release/wait-for-it.sh" - name: verify .github folder is not changed if: steps.filter.outputs.github == 'true' run: | From 9784d29abe19953763fef75fd6bbdad89e09f297 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 16:59:18 +0300 Subject: [PATCH 123/130] Debug new filters Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 2 +- .github/workflows/build-iroha1-fork.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 2d84ade6392..1969d42509a 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -48,7 +48,7 @@ jobs: - ".github/**" dockerfile: - "**/Dockerfile" - - "docker/release/entrypoint.sh" + # - "docker/release/entrypoint.sh" # - "docker/release/wait-for-it.sh" - name: verify .github folder is not changed diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 002ecf3eec2..4f48e679fd7 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -42,7 +42,7 @@ jobs: - ".github/**" dockerfile: - "**/Dockerfile" - - "docker/release/entrypoint.sh" + # - "docker/release/entrypoint.sh" # - "docker/release/wait-for-it.sh" - name: verify .github folder is not changed if: steps.filter.outputs.github == 'true' From 88e5318a36812cece6be64310ecec3d1ce643f49 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 6 Apr 2022 17:01:09 +0300 Subject: [PATCH 124/130] Debug new filters Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 6 +++--- .github/workflows/build-iroha1-fork.yml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 1969d42509a..532ccf16421 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -48,8 +48,8 @@ jobs: - ".github/**" dockerfile: - "**/Dockerfile" - # - "docker/release/entrypoint.sh" - # - "docker/release/wait-for-it.sh" + - "docker/release/entrypoint.sh" + - "docker/release/wait-for-it.sh" - name: verify .github folder is not changed if: steps.filter.outputs.github == 'true' @@ -740,7 +740,7 @@ jobs: docker-R: &job_docker_image_release needs: - build-UR - - generate_matrixespackages: write + - generate_matrixes runs-on: [ self-hosted, Linux ] #ubuntu-latest # strategy: *strategy_ubuntu_release # if: *if_ubuntu_release diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 4f48e679fd7..f6f7e6548f1 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -42,8 +42,8 @@ jobs: - ".github/**" dockerfile: - "**/Dockerfile" - # - "docker/release/entrypoint.sh" - # - "docker/release/wait-for-it.sh" + - "docker/release/entrypoint.sh" + - "docker/release/wait-for-it.sh" - name: verify .github folder is not changed if: steps.filter.outputs.github == 'true' run: | @@ -1299,7 +1299,7 @@ jobs: docker-R: needs: - build-UR - - generate_matrixespackages: write + - generate_matrixes runs-on: [self-hosted, Linux] #ubuntu-latest # strategy: *strategy_ubuntu_release # if: *if_ubuntu_release From ab7aaed8ee2f7a0dc648821ad30662eda61cf35f Mon Sep 17 00:00:00 2001 From: safinsaf Date: Fri, 8 Apr 2022 13:57:28 +0300 Subject: [PATCH 125/130] Refactor to run only by comment Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 35 ++++++++++++++++++++++--- .github/workflows/build-iroha1-fork.yml | 26 +++++++++++++++--- 2 files changed, 53 insertions(+), 8 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 532ccf16421..d719d3e2b71 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -1,6 +1,6 @@ name: Iroha1-fork -# The only write permission requird is packages +# The only write permission required is packages permissions: actions: read checks: read @@ -15,8 +15,12 @@ permissions: ## This workflow is created for pull requests from forks only and has less permissions than build-iroha1 workflow on: - pull_request_target: - branches: [ main, support/1.*, edge, develop, feature/DOPS-1651/enable-fork-build ] ## target branches + #pull_request_target: + # branches: [ main, support/1.*, edge, develop, feature/DOPS-1651/enable-fork-build ] ## target branches + + + issue_comment: + types: [created] env: DOCKERHUB_ORG: hyperledger @@ -24,14 +28,37 @@ env: jobs: + ## This step allows to skip the workflow completely for pull_requests from the same repo ## Also it checks that that .github folder and Dockerfiles are not changed check_if_pull_request_comes_from_fork: + runs-on: ubuntu-20.04 #ubuntu-latest name: Pull requests from forks should use other workflow - if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name }} + if: ${{ github.event.issue.comment.body == "Launch build" }} steps: + - + name: Show context + run: | + echo "::group::GitHub context" + cat <<'END' + ${{ toJson(github) }} + END + echo "::endgroup::" + echo "::group::GitHub needs" + cat <<'END' + ${{ toJson(needs) }} + END + echo "::endgroup::" + + + - name: Allow build + if: + run: | + "Lunching build" + + - &step_checkout_head name: Checkout head uses: actions/checkout@v2 diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index f6f7e6548f1..20f8f77f8a5 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -2,7 +2,7 @@ ## Generated from build-iroha1-fork.src.yml with make-workflows.sh name: Iroha1-fork -# The only write permission requird is packages +# The only write permission required is packages permissions: actions: read checks: read @@ -16,8 +16,10 @@ permissions: statuses: read ## This workflow is created for pull requests from forks only and has less permissions than build-iroha1 workflow on: - pull_request_target: - branches: [main, support/1.*, edge, develop, feature/DOPS-1651/enable-fork-build] ## target branches + #pull_request_target: + # branches: [ main, support/1.*, edge, develop, feature/DOPS-1651/enable-fork-build ] ## target branches + issue_comment: + types: [created] env: DOCKERHUB_ORG: hyperledger jobs: @@ -26,8 +28,24 @@ jobs: check_if_pull_request_comes_from_fork: runs-on: ubuntu-20.04 #ubuntu-latest name: Pull requests from forks should use other workflow - if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name }} + if: ${{ github.event.issue.comment.body == "Launch build" }} steps: + - name: Show context + run: | + echo "::group::GitHub context" + cat <<'END' + ${{ toJson(github) }} + END + echo "::endgroup::" + echo "::group::GitHub needs" + cat <<'END' + ${{ toJson(needs) }} + END + echo "::endgroup::" + - name: Allow build + if: + run: | + "Lunching build" - name: Checkout head uses: actions/checkout@v2 with: From 3afd34bf696c67853b32c5657e9c48734267d317 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Fri, 8 Apr 2022 14:03:37 +0300 Subject: [PATCH 126/130] Refactor to run only by comment Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index d719d3e2b71..3e4938c8af9 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -21,6 +21,8 @@ on: issue_comment: types: [created] + branches: [ main, support/1.*, edge, develop, feature/DOPS-1651/enable-fork-build ] + env: DOCKERHUB_ORG: hyperledger From 8fc7b95c0d8ef7302959ce67fbe1acda27be7a5c Mon Sep 17 00:00:00 2001 From: safinsaf Date: Fri, 8 Apr 2022 14:08:00 +0300 Subject: [PATCH 127/130] Refactor to run only by comment Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 2 +- .github/workflows/build-iroha1-fork.yml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 3e4938c8af9..bb565a3500b 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -21,7 +21,7 @@ on: issue_comment: types: [created] - branches: [ main, support/1.*, edge, develop, feature/DOPS-1651/enable-fork-build ] + branches: [ main, support/1.*, edge, develop, feature/DOPS-1651/enable-fork-build ] env: diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 20f8f77f8a5..86ebadd42d8 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -20,6 +20,7 @@ on: # branches: [ main, support/1.*, edge, develop, feature/DOPS-1651/enable-fork-build ] ## target branches issue_comment: types: [created] + branches: [main, support/1.*, edge, develop, feature/DOPS-1651/enable-fork-build] env: DOCKERHUB_ORG: hyperledger jobs: From 429a6ecfccf744a53cb6d8a2293c460ffa652e84 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 13 Apr 2022 13:35:20 +0300 Subject: [PATCH 128/130] Try environments Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 29 +++++++------------------ .github/workflows/build-iroha1-fork.yml | 20 +++++++---------- 2 files changed, 16 insertions(+), 33 deletions(-) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index bb565a3500b..9c7f85efb88 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -15,13 +15,11 @@ permissions: ## This workflow is created for pull requests from forks only and has less permissions than build-iroha1 workflow on: - #pull_request_target: - # branches: [ main, support/1.*, edge, develop, feature/DOPS-1651/enable-fork-build ] ## target branches - - - issue_comment: - types: [created] + pull_request_target: branches: [ main, support/1.*, edge, develop, feature/DOPS-1651/enable-fork-build ] + paths-ignore: + - '**.md' + - '**.rst' env: @@ -29,17 +27,13 @@ env: jobs: - - ## This step allows to skip the workflow completely for pull_requests from the same repo ## Also it checks that that .github folder and Dockerfiles are not changed check_if_pull_request_comes_from_fork: - runs-on: ubuntu-20.04 #ubuntu-latest - name: Pull requests from forks should use other workflow - if: ${{ github.event.issue.comment.body == "Launch build" }} + name: Pull requests from forks should use this workflow + if: github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name steps: - - name: Show context run: | @@ -53,13 +47,6 @@ jobs: ${{ toJson(needs) }} END echo "::endgroup::" - - - - name: Allow build - if: - run: | - "Lunching build" - - &step_checkout_head name: Checkout head @@ -94,9 +81,9 @@ jobs: generate_matrixes: - runs-on: ubuntu-20.04 #ubuntu-latest + environment: test-env + runs-on: ubuntu-20.04 needs: check_if_pull_request_comes_from_fork - #container: ubuntu:latest if: ${{ (github.event_name != 'comment') || ( github.event.comment && github.event.issue.pull_request && startsWith(github.event.comment.body, '/build') ) }} diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 86ebadd42d8..70401cda312 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -16,11 +16,11 @@ permissions: statuses: read ## This workflow is created for pull requests from forks only and has less permissions than build-iroha1 workflow on: - #pull_request_target: - # branches: [ main, support/1.*, edge, develop, feature/DOPS-1651/enable-fork-build ] ## target branches - issue_comment: - types: [created] + pull_request_target: branches: [main, support/1.*, edge, develop, feature/DOPS-1651/enable-fork-build] + paths-ignore: + - '**.md' + - '**.rst' env: DOCKERHUB_ORG: hyperledger jobs: @@ -28,8 +28,8 @@ jobs: ## Also it checks that that .github folder and Dockerfiles are not changed check_if_pull_request_comes_from_fork: runs-on: ubuntu-20.04 #ubuntu-latest - name: Pull requests from forks should use other workflow - if: ${{ github.event.issue.comment.body == "Launch build" }} + name: Pull requests from forks should use this workflow + if: github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name steps: - name: Show context run: | @@ -43,10 +43,6 @@ jobs: ${{ toJson(needs) }} END echo "::endgroup::" - - name: Allow build - if: - run: | - "Lunching build" - name: Checkout head uses: actions/checkout@v2 with: @@ -74,9 +70,9 @@ jobs: echo "Pull requests from forks are not allowed to change Dockerfiles" false generate_matrixes: - runs-on: ubuntu-20.04 #ubuntu-latest + environment: test-env + runs-on: ubuntu-20.04 needs: check_if_pull_request_comes_from_fork - #container: ubuntu:latest if: ${{ (github.event_name != 'comment') || ( github.event.comment && github.event.issue.pull_request && startsWith(github.event.comment.body, '/build') ) }} steps: - name: Show context From 0775ecc98999a0c5e03304931388bb74c22b5ae7 Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 13 Apr 2022 14:08:29 +0300 Subject: [PATCH 129/130] Add require review to iroha-builder and prepare-env Signed-off-by: safinsaf --- .github/build-iroha1-fork.src.yml | 3 +++ .github/build-iroha1.src.yml | 3 +++ .github/workflows/build-iroha1-fork.yml | 3 +++ .github/workflows/build-iroha1.yml | 3 +++ 4 files changed, 12 insertions(+) diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index 9c7f85efb88..d9ec4656959 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -193,6 +193,7 @@ jobs: matrix_dockerimage_debug: ${{steps.matrixes.outputs.matrix_dockerimage_debug}} Docker-iroha-builder: + environment: test-env needs: check_if_pull_request_comes_from_fork runs-on: ubuntu-20.04 #ubuntu-latest #[ self-hosted, Linux ] steps: @@ -622,6 +623,7 @@ jobs: ## Just to align picture prepare-macos-env: needs: check_if_pull_request_comes_from_fork + environment: test-env runs-on: macos-latest steps: - *step_show_context @@ -690,6 +692,7 @@ jobs: ## Just to align picture prepare-windows-env: needs: check_if_pull_request_comes_from_fork + environment: test-env runs-on: windows-latest steps: - *step_show_context diff --git a/.github/build-iroha1.src.yml b/.github/build-iroha1.src.yml index a3133098056..c3080d95a37 100644 --- a/.github/build-iroha1.src.yml +++ b/.github/build-iroha1.src.yml @@ -49,6 +49,9 @@ on: tags: '**' pull_request: branches: [ main, support/1.*, edge, develop, feature/DOPS-1651/enable-fork-build ] ## target branches + paths-ignore: + - '**.md' + - '**.rst' workflow_dispatch: ## NOTE: Able to run via cmdline: gh workflow run Iroha1 inputs: diff --git a/.github/workflows/build-iroha1-fork.yml b/.github/workflows/build-iroha1-fork.yml index 70401cda312..b567491b821 100644 --- a/.github/workflows/build-iroha1-fork.yml +++ b/.github/workflows/build-iroha1-fork.yml @@ -175,6 +175,7 @@ jobs: matrix_dockerimage_release: ${{steps.matrixes.outputs.matrix_dockerimage_release}} matrix_dockerimage_debug: ${{steps.matrixes.outputs.matrix_dockerimage_debug}} Docker-iroha-builder: + environment: test-env needs: check_if_pull_request_comes_from_fork runs-on: ubuntu-20.04 #ubuntu-latest #[ self-hosted, Linux ] steps: @@ -909,6 +910,7 @@ jobs: ## Just to align picture prepare-macos-env: needs: check_if_pull_request_comes_from_fork + environment: test-env runs-on: macos-latest steps: - name: Show context @@ -1208,6 +1210,7 @@ jobs: ## Just to align picture prepare-windows-env: needs: check_if_pull_request_comes_from_fork + environment: test-env runs-on: windows-latest steps: - name: Show context diff --git a/.github/workflows/build-iroha1.yml b/.github/workflows/build-iroha1.yml index 9d0356c4d7f..588fa2953e7 100644 --- a/.github/workflows/build-iroha1.yml +++ b/.github/workflows/build-iroha1.yml @@ -49,6 +49,9 @@ on: tags: '**' pull_request: branches: [main, support/1.*, edge, develop, feature/DOPS-1651/enable-fork-build] ## target branches + paths-ignore: + - '**.md' + - '**.rst' workflow_dispatch: ## NOTE: Able to run via cmdline: gh workflow run Iroha1 inputs: From d80151b57b614ce4d152eb33f9a6faa19d8f173c Mon Sep 17 00:00:00 2001 From: safinsaf Date: Wed, 13 Apr 2022 15:43:38 +0300 Subject: [PATCH 130/130] Update workflow Readme, update comments, remove odd branches, prepare pr for merge Signed-off-by: safinsaf --- .github/_README.md | 33 ++++++++++++++-- .github/build-iroha1-fork.src.yml | 25 +++++++----- .github/build-iroha1.src.yml | 52 +++---------------------- .github/workflows/build-iroha1-fork.yml | 24 ++++++++---- .github/workflows/build-iroha1.yml | 51 ++++++------------------ 5 files changed, 77 insertions(+), 108 deletions(-) diff --git a/.github/_README.md b/.github/_README.md index e8b4c9e3e13..df589927be1 100644 --- a/.github/_README.md +++ b/.github/_README.md @@ -6,9 +6,23 @@ GitHub Actions CI for Iroha --------------------- -USAGE +### Workflows + +There are GitHub Actions Workflows called [`Iroha1`](build-iroha1.src.yml) and [`Iroha1-fork`](build-iroha1-fork.src.yml). + + +USAGE of Iroha1-fork ----- -GitHub Actions Workflow [`Iroha1`](build-iroha1.src.yml) solves task of automated build and deployment Iroha1. +GitHub Actions Workflow [`Iroha1-fork`](build-iroha1-fork.src.yml) solves task of automated build and deployment of Iroha1 from forks. + +Runs on **pull request** from forks to Iroha1 main and development branches. + +The workflow is started on pull request creation or update. The workflow is paused on steps that require build of untrusted code. Maintainers are notified to review the code and allow build and deployment. + + +USAGE of Iroha1 +----- +GitHub Actions Workflow [`Iroha1`](build-iroha1.src.yml) solves task of automated build and deployment Iroha1 from Hyperledger/iroha repository. There are events when it is running: - on **pull request** to Iroha1 main and development branches - on **push** to main or development branches including event when PR is **merged** @@ -22,12 +36,17 @@ Default `buildspec` is _`/build all`_ Build matrix is a way to select among number of configurations to be built. Build matrix is generated from buildspec string and handled by script [`chatops-gen-matrix.sh`](./chatops-gen-matrix.sh) -## List of files +List of files +----- - `build-iroha1.src.yml` Main file here. GitHub workflow YAML description with ANCHORS, code is not duplicated. - IMPORTANT: regeneration required after after edit, which is automated with pre-commit. + IMPORTANT: regeneration required after edit, which is automated with pre-commit. +- `build-iroha1-fork.src.yml` + Same as previous, but for forks - `workflows/build-iroha1.yml` Result worflow taken by GitHub and generated with make-workflows script. Long file of repeated code. DO NOT EDIT MANUALLY. +- `workflows/build-iroha1.yml` + Same as previous, but for forks - `make-workflows.sh` A tool to generate workflows/*.yml from *.src.yml - evaluates anchors. [Read the docs](_README.make-workflows.md). - `chatops-gen-matrix.sh` @@ -65,3 +84,9 @@ Build matrix is generated from buildspec string and handled by script [`chatops- See docs of make-workflows. Use instead of pre-commit as `ln -s ../../.github/pre-commit-hook.sh .git/hooks/pre-commit`, reserv alternative. - `TESTS_ALLOWED_TO_FAIL` One day tests of Iroha became failing. To fix CI and postpone fixing tests, this file was invented. It allows CI to pass even when listed tests are failing. DO NOT USE UNLESS YOU DEFINITELY KNOW WHAT'S GOING. KEEP IT EMPTY. + +Worth noting +----- +None of workflows run for PRs that update only .md and .rst files. As sourse code of Iroha and dependencies do not change, building and testing is redundant. + +Forks are not allowed to change `.github` folder, Dockerfiles and scripts in `docker` folder \ No newline at end of file diff --git a/.github/build-iroha1-fork.src.yml b/.github/build-iroha1-fork.src.yml index d9ec4656959..337889d80c5 100644 --- a/.github/build-iroha1-fork.src.yml +++ b/.github/build-iroha1-fork.src.yml @@ -13,10 +13,10 @@ permissions: security-events: read statuses: read -## This workflow is created for pull requests from forks only and has less permissions than build-iroha1 workflow +## This workflow is created for pull requests from forks and has less permissions than build-iroha1 workflow on: pull_request_target: - branches: [ main, support/1.*, edge, develop, feature/DOPS-1651/enable-fork-build ] + branches: [ main, support/1.*, edge, develop] paths-ignore: - '**.md' - '**.rst' @@ -26,9 +26,8 @@ env: DOCKERHUB_ORG: hyperledger jobs: - - ## This step allows to skip the workflow completely for pull_requests from the same repo - ## Also it checks that that .github folder and Dockerfiles are not changed + ## This job checks if PRs is from fork + ## Also checks that .github folder, Dockerfiles and scripts in docker directory are not changed check_if_pull_request_comes_from_fork: runs-on: ubuntu-20.04 #ubuntu-latest name: Pull requests from forks should use this workflow @@ -73,13 +72,20 @@ jobs: echo "Pull requests from forks are not allowed to change .github folder" false - - name: verify Dockerfiles are not changed + - name: verify Dockerfiles and scripts in docker directory are not changed if: steps.filter.outputs.dockerfile == 'true' run: | echo "Pull requests from forks are not allowed to change Dockerfiles" false + ## This job is to generate build matrixes for build jobs + ## The matrixes depend on what is requeted to be build + ## At the moment there are several options: + ## - default on pushes, pull requests + ## - on comment to pull request according to comment message (chat-ops) + ## - on workflow_dispatch according to its build_spec + ## - on schedule '/build all' generate_matrixes: environment: test-env runs-on: ubuntu-20.04 @@ -145,8 +151,7 @@ jobs: true else #echo >/tmp/comment_body "/build debug; /build ubuntu release debug normal" - echo >/tmp/comment_body "/build all skip_testing" - #echo >/tmp/comment_body "/build ubuntu debug clang-10 normal" + echo >/tmp/comment_body "/build all" fi ;; esac - @@ -192,6 +197,9 @@ jobs: matrix_dockerimage_release: ${{steps.matrixes.outputs.matrix_dockerimage_release}} matrix_dockerimage_debug: ${{steps.matrixes.outputs.matrix_dockerimage_debug}} + ## Build docker image named 'hyperledger/iroha-builder' with all stuff to compile iroha and its dependancies + ## The result docker image is pushed with tags :pr-NUMBER, :commit-HASH, :branch-name, :tag-name, + ## and conditional tags :edge for development branch, and :latest for git-tags. Docker-iroha-builder: environment: test-env needs: check_if_pull_request_comes_from_fork @@ -755,7 +763,6 @@ jobs: ## Those docker image tags could be extended with suffixes with compiler and build type like ## -gcc10, -clang, -debug, -gcc10-debug. Like :latest-debug, :main-debug, :1.3.0-gcc10-debug. ## Result image name could look like: hyperledger/iroha:pr-1117, hyperledger/iroha:nightly. - ## Note: image is push only when DockerHub login-token pair available - not to PRs from forks docker-R: &job_docker_image_release needs: - build-UR diff --git a/.github/build-iroha1.src.yml b/.github/build-iroha1.src.yml index c3080d95a37..c3b041720c5 100644 --- a/.github/build-iroha1.src.yml +++ b/.github/build-iroha1.src.yml @@ -45,10 +45,10 @@ name: Iroha1 ## TODO make these different workflows - reduce number of conditionals inside jobs like 'step_detect_commented_pr' on: push: - branches: [ main, support/1.*, edge, develop, test-ci, gha, gha/*, gha-*, \*-with-gha ] + branches: [ main, support/1.*, edge, develop] tags: '**' pull_request: - branches: [ main, support/1.*, edge, develop, feature/DOPS-1651/enable-fork-build ] ## target branches + branches: [ main, support/1.*, edge, develop] ## target branches paths-ignore: - '**.md' - '**.rst' @@ -95,7 +95,7 @@ jobs: name: Pull requests from forks should use other workflow if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name }} steps: - - + - &step_show_context name: Show context run: | echo "::group::GitHub context" @@ -135,7 +135,7 @@ jobs: uses: actions/checkout@v2 with: &step_checkout_with ref: ${{env.PR_REF}} ## not empty on issue_comment, else default value GITHUB_REF - repository: ${{env.PR_REPO}} ## not empty on issue_comment, else default value github.repository, required by forks + repository: ${{env.PR_REPO}} ## not empty on issue_comment, else default value github.repository - run: sudo snap install yq - @@ -152,19 +152,7 @@ jobs: github.event.issue.pull_request && startsWith(github.event.comment.body, '/build') }} steps: - - &step_show_context - name: Show context - run: | - echo "::group::GitHub context" - cat <<'END' - ${{ toJson(github) }} - END - echo "::endgroup::" - echo "::group::GitHub needs" - cat <<'END' - ${{ toJson(needs) }} - END - echo "::endgroup::" + - *step_show_context - name: Reaction run: | @@ -282,7 +270,6 @@ jobs: ## Build docker image named 'hyperledger/iroha-builder' with all stuff to compile iroha and its dependancies ## The result docker image is pushed with tags :pr-NUMBER, :commit-HASH, :branch-name, :tag-name, ## and conditional tags :edge for development branch, and :latest for git-tags. - ## Note: image is push only when DockerHub login-token pair available - not to PRs from forks. Docker-iroha-builder: needs: check_workflow_yaml_coressponds_to_src_yaml runs-on: ubuntu-20.04 #ubuntu-latest #[ self-hosted, Linux ] @@ -414,34 +401,6 @@ jobs: run: | echo "::set-output name=container::$DOCKERHUB_ORG/iroha-builder:$dockertag" docker pull "$DOCKERHUB_ORG/iroha-builder:$dockertag" - - - name: Possible ERROR, Dockerfile edited, image was build, but seems not pushed, CANNOT PULL. - if: failure() - #if: ${{ steps.docker_login.outcome != 'success' || steps.build_and_push.outcome != 'success' }} - env: - container: ${{steps.dockertag_already.outputs.container}} - dockertag: ${{env.dockertag}} - run: | - cat </tmp/comment_body "/build debug; /build ubuntu release debug normal" - echo >/tmp/comment_body "/build all skip_testing" - #echo >/tmp/comment_body "/build ubuntu debug clang-10 normal" + echo >/tmp/comment_body "/build all" fi ;; esac - name: Generate matrixes @@ -174,6 +180,9 @@ jobs: matrix_windows: ${{steps.matrixes.outputs.matrix_windows}} matrix_dockerimage_release: ${{steps.matrixes.outputs.matrix_dockerimage_release}} matrix_dockerimage_debug: ${{steps.matrixes.outputs.matrix_dockerimage_debug}} + ## Build docker image named 'hyperledger/iroha-builder' with all stuff to compile iroha and its dependancies + ## The result docker image is pushed with tags :pr-NUMBER, :commit-HASH, :branch-name, :tag-name, + ## and conditional tags :edge for development branch, and :latest for git-tags. Docker-iroha-builder: environment: test-env needs: check_if_pull_request_comes_from_fork @@ -1313,7 +1322,6 @@ jobs: ## Those docker image tags could be extended with suffixes with compiler and build type like ## -gcc10, -clang, -debug, -gcc10-debug. Like :latest-debug, :main-debug, :1.3.0-gcc10-debug. ## Result image name could look like: hyperledger/iroha:pr-1117, hyperledger/iroha:nightly. - ## Note: image is push only when DockerHub login-token pair available - not to PRs from forks docker-R: needs: - build-UR diff --git a/.github/workflows/build-iroha1.yml b/.github/workflows/build-iroha1.yml index 588fa2953e7..fd5a7c2938e 100644 --- a/.github/workflows/build-iroha1.yml +++ b/.github/workflows/build-iroha1.yml @@ -45,10 +45,10 @@ name: Iroha1 ## TODO make these different workflows - reduce number of conditionals inside jobs like 'step_detect_commented_pr' on: push: - branches: [main, support/1.*, edge, develop, test-ci, gha, gha/*, gha-*, \*-with-gha] + branches: [main, support/1.*, edge, develop] tags: '**' pull_request: - branches: [main, support/1.*, edge, develop, feature/DOPS-1651/enable-fork-build] ## target branches + branches: [main, support/1.*, edge, develop] ## target branches paths-ignore: - '**.md' - '**.rst' @@ -127,7 +127,7 @@ jobs: uses: actions/checkout@v2 with: ref: ${{env.PR_REF}} ## not empty on issue_comment, else default value GITHUB_REF - repository: ${{env.PR_REPO}} ## not empty on issue_comment, else default value github.repository, required by forks + repository: ${{env.PR_REPO}} ## not empty on issue_comment, else default value github.repository - run: sudo snap install yq - name: Check if .github/workflows/*.yml correspond to *.src.yml run: | @@ -197,7 +197,7 @@ jobs: uses: actions/checkout@v2 with: ref: ${{env.PR_REF}} ## not empty on issue_comment, else default value GITHUB_REF - repository: ${{env.PR_REPO}} ## not empty on issue_comment, else default value github.repository, required by forks + repository: ${{env.PR_REPO}} ## not empty on issue_comment, else default value github.repository - name: Generate matrix for build triggered by chat-ops - comment to PR if: github.event.issue.pull_request && github.event.comment id: comment_body @@ -281,7 +281,6 @@ jobs: ## Build docker image named 'hyperledger/iroha-builder' with all stuff to compile iroha and its dependancies ## The result docker image is pushed with tags :pr-NUMBER, :commit-HASH, :branch-name, :tag-name, ## and conditional tags :edge for development branch, and :latest for git-tags. - ## Note: image is push only when DockerHub login-token pair available - not to PRs from forks. Docker-iroha-builder: needs: check_workflow_yaml_coressponds_to_src_yaml runs-on: ubuntu-20.04 #ubuntu-latest #[ self-hosted, Linux ] @@ -333,7 +332,7 @@ jobs: uses: actions/checkout@v2 with: ref: ${{env.PR_REF}} ## not empty on issue_comment, else default value GITHUB_REF - repository: ${{env.PR_REPO}} ## not empty on issue_comment, else default value github.repository, required by forks + repository: ${{env.PR_REPO}} ## not empty on issue_comment, else default value github.repository - name: Determine dockertag id: dockertag env: @@ -436,33 +435,6 @@ jobs: run: | echo "::set-output name=container::$DOCKERHUB_ORG/iroha-builder:$dockertag" docker pull "$DOCKERHUB_ORG/iroha-builder:$dockertag" - - name: Possible ERROR, Dockerfile edited, image was build, but seems not pushed, CANNOT PULL. - if: failure() - #if: ${{ steps.docker_login.outcome != 'success' || steps.build_and_push.outcome != 'success' }} - env: - container: ${{steps.dockertag_already.outputs.container}} - dockertag: ${{env.dockertag}} - run: | - cat <