From 936f2a3f21adb20e2ef80cc6e0ad6af533c11d3c Mon Sep 17 00:00:00 2001 From: Ryan Danehy Date: Mon, 16 Oct 2023 14:17:25 -0700 Subject: [PATCH] Ascent Ci for ReSolve and Github (#4) * add pipeline for ascent * Remove push on MR * Update .github/workflows/ornl_ascent_mirror.yaml Co-authored-by: pelesh --------- Co-authored-by: ryan.danehy@pnnl.gov Co-authored-by: pelesh --- .github/pnnl_mirror.yaml | 33 ++++++++++++++++++++ .github/workflows/.clang-format | 9 ++++++ .github/workflows/.cmake-format.py | 19 ++++++++++++ .github/workflows/ornl_ascent_mirror.yaml | 38 +++++++++++++++++++++++ .gitlab-ci.yml | 38 ++++++++++++++++++++++- 5 files changed, 136 insertions(+), 1 deletion(-) create mode 100644 .github/pnnl_mirror.yaml create mode 100644 .github/workflows/.clang-format create mode 100644 .github/workflows/.cmake-format.py create mode 100644 .github/workflows/ornl_ascent_mirror.yaml diff --git a/.github/pnnl_mirror.yaml b/.github/pnnl_mirror.yaml new file mode 100644 index 00000000..65cf58d1 --- /dev/null +++ b/.github/pnnl_mirror.yaml @@ -0,0 +1,33 @@ +name: PNNL Mirror + +# triggers a github action everytime there is a push or mr +on: + pull_request: + push: + branches: + - develop + - main + +jobs: + # To test on HPC resources we must first mirror the repo and then trigger a pipeline + push: + # Latest Ubuntu as of Feb 2023 is 20.04 + runs-on: ubuntu-22.04 + steps: + # Action checks-out your repository under $GITHUB_WORKSPACE, so your workflow can access it. + - uses: actions/checkout@v1 + + # Necessary to get branch name independent of PR/push + - name: Extract branch name + shell: bash + run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT + id: extract_branch + + # Action for mirroring your commits to a different remote repository + - uses: yesolutions/mirror-action@master + # Give actions access to some secrets + with: + GIT_PUSH_ARGS: '--tags --force --push-option=ci.skip' + REMOTE: 'https://gitlab.pnnl.gov/exasgd/frameworks/exago-github-mirror' + GIT_USERNAME: ${{ secrets.GIT_USER }} + GIT_PASSWORD: ${{ secrets.GIT_PASSWORD }} diff --git a/.github/workflows/.clang-format b/.github/workflows/.clang-format new file mode 100644 index 00000000..b8cef3e9 --- /dev/null +++ b/.github/workflows/.clang-format @@ -0,0 +1,9 @@ +# Documentation about the style options and their meaning +# https://releases.llvm.org/12.0.0/tools/clang/docs/ClangFormatStyleOptions.html + +Language: Cpp +AccessModifierOffset: 0 +AlignConsecutiveMacros: true +BreakBeforeBraces: Linux +ColumnLimit: 150 +ConstructorInitializerIndentWidth: 2 diff --git a/.github/workflows/.cmake-format.py b/.github/workflows/.cmake-format.py new file mode 100644 index 00000000..2fb7cd4b --- /dev/null +++ b/.github/workflows/.cmake-format.py @@ -0,0 +1,19 @@ +# -*- Python -*- + +with section("format"): + + # How wide to allow formatted cmake files + line_width = 80 + + # How many spaces to tab for indent + tab_size = 2 + + # If true, separate flow control names from their parentheses with a space + separate_ctrl_name_with_space = False + + # If true, separate function names from parentheses with a space + separate_fn_name_with_space = False + + # If a statement is wrapped to more than one line, than dangle the closing + # parenthesis on its own line. + dangle_parens = True diff --git a/.github/workflows/ornl_ascent_mirror.yaml b/.github/workflows/ornl_ascent_mirror.yaml new file mode 100644 index 00000000..9e2cd805 --- /dev/null +++ b/.github/workflows/ornl_ascent_mirror.yaml @@ -0,0 +1,38 @@ +name: ORNL Ascent Mirror + +# triggers a github action everytime there is a push or mr +on: + push: + +jobs: + # To test on HPC resources we must first mirror the repo and then trigger a pipeline + push: + # Latest Ubuntu as of Feb 2023 is 20.04 + runs-on: ubuntu-22.04 + steps: + # Action checks-out your repository under $GITHUB_WORKSPACE, so your workflow can access it. + - uses: actions/checkout@v1 + + # Necessary to get branch name independent of PR/push + - name: Extract branch name + shell: bash + run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT + id: extract_branch + + - name: git checkout + run: git switch ${{ steps.extract_branch.outputs.branch }} + + # Action for mirroring your commits to a different remote repository + - uses: yesolutions/mirror-action@master + # Give actions access to some secrets + with: + PUSH_ALL_REFS: "false" + GIT_REF: ${{ steps.extract_branch.outputs.branch }} + GIT_PUSH_ARGS: '--tags --force --push-option=ci.skip' + REMOTE: 'https://code.ornl.gov/ecpcitest/exasgd/resolve' + GIT_USERNAME: ${{ secrets.GIT_USER }} + GIT_PASSWORD: ${{ secrets.ORNL_ASCENT_GIT_PASSWORD }} + + # Trigger CI pipeline since it was skipped in the above push + - name: Trigger Pipeline + run: curl -X POST -F token=${{ secrets.ORNL_ASCENT_PIPELINE_TRIGGER }} -F ref=${{ steps.extract_branch.outputs.branch }} https://code.ornl.gov/api/v4/projects/13292/trigger/pipeline diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6e52ef54..963b2c69 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -48,4 +48,40 @@ Ascent-Build-Test: - batch extends: - .resolve_build_script - - .ornl_environment_template \ No newline at end of file + - .ornl_environment_template + +.report-status: + variables: + GIT_STRATEGY: none + STATUS_PROJECT: ORNL/ReSolve + MY_CLUSTER: Ascent + tags: + - nobatch + extends: + - .ornl_environment_template + script: + # For complete details on the GitLab API please see: + # https://docs.gitlab.com/ee/api/commits.html#post-the-build-status-to-a-commit + # Make sure to create the token with Developer level access and API scope + - | + curl -L -X POST -H @${GITHUB_CURL_HEADERS} https://api.github.com/repos/${STATUS_PROJECT}/statuses/${CI_COMMIT_SHA} -d "{\"state\":\"${CI_JOB_NAME}\",\"target_url\":\"${CI_PIPELINE_URL}\",\"context\":\"${MY_CLUSTER}\"}" + environment: + name: reporting-gitlab + +pending: + extends: + - .report-status + stage: .pre + +success: + stage: .post + extends: + - .report-status + +failure: + stage: .post + extends: + - .report-status + rules: + - when: on_failure +