diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index a13e807029..774479e130 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -41,6 +41,10 @@ on: # allow calling from other repos in the ReactionMechanismGenerator organization workflow_call: inputs: + rmg-py-branch: + default: "main" + required: false + type: string rmg-db-branch: # if calling from RMG-database, must provide a branch required: true @@ -52,23 +56,98 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true +# if running on RMG-Py but requiring changes on an un-merged branch of RMG-database, replace +# main with the name of the branch +env: + RMG_DATABASE_BRANCH: main + jobs: + clone: + runs-on: ubuntu-latest + # skip scheduled runs from forks + if: ${{ !( github.repository != 'ReactionMechanismGenerator/RMG-Py' && github.event_name == 'schedule' ) }} + steps: + # Option 1: calling from branch on RMG/RMG-Py and using branch on RMG/RMG-database + - name: Checkout RMG-Py + if: github.repository == 'ReactionMechanismGenerator/RMG-Py' + uses: actions/checkout@v3 + with: + repository: ReactionMechanismGenerator/RMG-Py + path: RMG-Py + - name: Checkout RMG-database + if: github.repository == 'ReactionMechanismGenerator/RMG-Py' + uses: actions/checkout@v3 + with: + repository: ReactionMechanismGenerator/RMG-database + path: RMG-database + ref: ${{ env.RMG_DATABASE_BRANCH }} + + # Option 2: calling from fork of RMG-Py and using branch on RMG/RMG-database + - name: Checkout RMG-Py + if: github.repository != 'ReactionMechanismGenerator/RMG-Py' && github.event.repository.name == 'RMG-Py' + uses: actions/checkout@v3 + with: + repository: ${{ github.repository_owner }}/RMG-Py + path: RMG-Py + - name: Checkout RMG-database + if: github.repository != 'ReactionMechanismGenerator/RMG-Py' && github.event.repository.name == 'RMG-Py' + uses: actions/checkout@v3 + with: + repository: ReactionMechanismGenerator/RMG-database + path: RMG-database + ref: ${{ env.RMG_DATABASE_BRANCH }} + + # Option 3: calling from branch on RMG-database + - name: Checkout RMG-Py + if: github.repository == 'ReactionMechanismGenerator/RMG-database' + uses: actions/checkout@v3 + with: + repository: ReactionMechanismGenerator/RMG-Py + path: RMG-Py + ref: ${{ inputs.rmg-py-branch }} + - name: Checkout RMG-database + if: github.repository == 'ReactionMechanismGenerator/RMG-database' + uses: actions/checkout@v3 + with: + repository: ReactionMechanismGenerator/RMG-database + path: RMG-database + ref: ${{ inputs.rmg-db-branch }} + + # Option 4: calling from fork on RMG-database + - name: Checkout RMG-Py + if: github.repository != 'ReactionMechanismGenerator/RMG-database' && github.event.repository.name == 'RMG-database' + uses: actions/checkout@v3 + with: + repository: ${{ github.repository_owner }}/RMG-Py + path: RMG-Py + ref: ${{ inputs.rmg-py-branch }} + - name: Checkout RMG-database + if: github.repository != 'ReactionMechanismGenerator/RMG-database' && github.event.repository.name == 'RMG-database' + uses: actions/checkout@v3 + with: + repository: ${{ github.repository_owner }}/RMG-database + path: RMG-database + ref: ${{ inputs.rmg-db-branch }} + + - name: Pass Repos to Build and Test + uses: actions/upload-artifact@v3 + with: + name: repositories + path: ${{ github.workspace }} + build-osx: + needs: clone runs-on: macos-latest # skip scheduled runs from forks - if: ${{ !( github.repository != 'ReactionMechanismGenerator/RMG-Py' && github.event_name == 'schedule' ) }} - env: - # if running on RMG-Py but requiring changes on an un-merged branch of RMG-database, replace - # main with the name of the branch - RMG_DATABASE_BRANCH: main defaults: run: shell: bash -l {0} steps: - - name: Checkout RMG-Py - uses: actions/checkout@v3 + - name: Fetch Repos + uses: actions/download-artifact@v3 with: - repository: ReactionMechanismGenerator/RMG-Py + name: repositories + path: ${{ github.workspace }} # configures the mamba environment manager and builds the environment - name: Setup Mambaforge Python 3.7 @@ -87,19 +166,6 @@ jobs: mamba info mamba list - # Clone RMG-database - - name: Clone RMG-database - Reusable Workflow - if: github.repository == 'ReactionMechanismGenerator/RMG-database' - run: | - cd .. - git clone -b ${{ inputs.rmg-db-branch }} https://github.com/ReactionMechanismGenerator/RMG-database.git - - - name: Clone RMG-database - RMG-Py - if: github.repository != 'ReactionMechanismGenerator/RMG-database' - run: | - cd .. - git clone -b $RMG_DATABASE_BRANCH https://github.com/ReactionMechanismGenerator/RMG-database.git - # modify env variables as directed in the RMG installation instructions - name: Set Environment Variables run: | @@ -114,24 +180,20 @@ jobs: make build-and-test-linux: + needs: clone runs-on: ubuntu-latest - # skip scheduled runs from forks - if: ${{ !( github.repository != 'ReactionMechanismGenerator/RMG-Py' && github.event_name == 'schedule' ) }} - env: - # if running on RMG-Py but requiring changes on an un-merged branch of RMG-database, replace - # main with the name of the branch - RMG_DATABASE_BRANCH: main - + env: # This is true only if this is a reference case for the regression testing: REFERENCE_JOB: ${{ github.ref == 'refs/heads/main' && github.repository == 'ReactionMechanismGenerator/RMG-Py' }} defaults: run: shell: bash -l {0} steps: - - name: Checkout RMG-Py - uses: actions/checkout@v3 + - name: Fetch Repos + uses: actions/download-artifact@v3 with: - repository: ReactionMechanismGenerator/RMG-Py + name: repositories + path: ${{ github.workspace }} # configures the mamba environment manager and builds the environment - name: Setup Mambaforge Python 3.7 @@ -150,19 +212,6 @@ jobs: mamba info mamba list - # Clone RMG-database - - name: Clone RMG-database - Reusable Workflow - if: github.repository == 'ReactionMechanismGenerator/RMG-database' - run: | - cd .. - git clone -b ${{ inputs.rmg-db-branch }} https://github.com/ReactionMechanismGenerator/RMG-database.git - - - name: Clone RMG-database - RMG-Py - if: github.repository != 'ReactionMechanismGenerator/RMG-database' - run: | - cd .. - git clone -b $RMG_DATABASE_BRANCH https://github.com/ReactionMechanismGenerator/RMG-database.git - # modify env variables as directed in the RMG installation instructions - name: Set Environment Variables run: |