From ffbf8512bcc69cde8d3c90e32243c91a50c8162b Mon Sep 17 00:00:00 2001 From: MiKyung Lee <58964324+mlee03@users.noreply.github.com> Date: Tue, 9 Jul 2024 13:00:01 -0400 Subject: [PATCH] reusable workflow CI - checkout corrrect repository (#90) * fix trigger mistake * fix spacking * update yaml files * rename lint.yaml * remove backup yaml file * simply pull request trigger * beloved lint --------- Co-authored-by: mlee03 --- .github/workflows/{lint.yml => lint.yaml} | 1 - .github/workflows/main_unit_tests.yaml | 55 +++++++---------------- 2 files changed, 17 insertions(+), 39 deletions(-) rename .github/workflows/{lint.yml => lint.yaml} (89%) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yaml similarity index 89% rename from .github/workflows/lint.yml rename to .github/workflows/lint.yaml index a768fdb9..0d15d592 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yaml @@ -1,7 +1,6 @@ name: "Lint" on: pull_request: - types: [opened, synchronize, reopened, ready_for_review, labeled, unlabeled] jobs: lint: diff --git a/.github/workflows/main_unit_tests.yaml b/.github/workflows/main_unit_tests.yaml index 9165727e..f5f6739b 100644 --- a/.github/workflows/main_unit_tests.yaml +++ b/.github/workflows/main_unit_tests.yaml @@ -1,68 +1,46 @@ -name: "Pace main unit tests" +name: "pace main unit tests" on: workflow_call: inputs: - ndsl_trigger: + component_trigger: type: boolean default: false required: false - fv3_trigger: - type: boolean - default: false - required: false - shield_trigger: - type: boolean - default: false + component_name: + type: string + default: '' required: false pull_request: - types: [opened, synchronize, reopened, ready_for_review, labeled, unlabeled] - # cancel running jobs if theres a newer push concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true -env: - github_repository: ${{github.event.repository.name}} - jobs: - main_unit_tests: + pace_main_unit_tests: runs-on: ubuntu-latest container: image: ghcr.io/noaa-gfdl/miniforge:mpich steps: - - name: Checkout pace if externally triggered - if: ${{ inputs.fv3_trigger || inputs.ndsl_trigger || inputs.shield_trigger }} + - name: external trigger Checkout pace/develop + if: ${{ inputs.component_trigger }} uses: actions/checkout@v4 with: submodules: 'recursive' repository: NOAA-GFDL/pace path: pace + ref: develop + + - name: external trigger Remove existing component in pace/develop + if: ${{ inputs.component_trigger }} + run: rm -rf ${GITHUB_WORKSPACE}/pace/${{inputs.component_name}} - - name: Checkout repo that triggered the workflow + - name: Checkout out hash that triggered CI uses: actions/checkout@v4 with: submodules: 'recursive' - path: ${{ env.github_repository }} - - - name: mv PyFV3 to pace - if: ${{inputs.fv3_trigger}} - run: | - rm -r ${GITHUB_WORKSPACE}/pace/pyFV3 - mv ${GITHUB_WORKSPACE}/${{env.github_repository}} ${GITHUB_WORKSPACE}/pace/pyFV3 - - - name: mv NDSL to pace - if: ${{inputs.ndsl_trigger}} - run: | - rm -r ${GITHUB_WORKSPACE}/pace/NDSL - mv ${GITHUB_WORKSPACE}/${{env.github_repository}} ${GITHUB_WORKSPACE}/pace/NDSL - - - name: mv pyShield to pace - if: ${{inputs.shield_trigger}} - run: | - rm -r ${GITHUB_WORKSPACE}/pace/pySHiELD - mv ${GITHUB_WORKSPACE}/${{env.github_repository}} ${GITHUB_WORKSPACE}/pace/pySHiELD + path: pace/${{inputs.component_name}} - name: install packages run: | @@ -73,8 +51,9 @@ jobs: - name: prepare input files run: | cd ${GITHUB_WORKSPACE}/pace + mkdir tests/main/input python3 examples/generate_eta_files.py - mkdir tests/main/input && mv eta*.nc tests/main/input/. + mv *eta*.nc tests/main/input - name: run tests run: |