Companion PR to NOAA-EMC/jcb/pull/7 #63
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Run JCB client testing with client changes | |
on: | |
push: | |
branches: | |
- develop | |
pull_request: | |
types: | |
- opened | |
- synchronize | |
- reopened | |
jobs: | |
jcb_integration_tests: | |
runs-on: ubuntu-latest | |
name: JCB Client Integration Tests | |
env: | |
JCB_REPO: https://github.com/NOAA-EMC/jcb.git | |
steps: | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.x' | |
- name: Add repo url to the environment | |
run: | | |
JCB_APP_REPO="${{ github.repository }}" | |
echo "JCB_APP_REPO=${JCB_APP_REPO}" >> $GITHUB_ENV | |
- name: Determine the name of the client branch | |
run: | | |
if [ "${{ github.event_name }}" == "pull_request" ]; then | |
JCB_APP_BRANCH=${{ github.head_ref }} | |
else | |
BRANCH_REF=${{ github.ref }} | |
JCB_APP_BRANCH=${BRANCH_REF#refs/heads/} | |
fi | |
echo "JCB_APP_BRANCH=$JCB_APP_BRANCH" >> $GITHUB_ENV | |
- name: Determine branch to use for main jcb repo | |
run: | | |
BRANCH_NAME=${{ env.JCB_APP_BRANCH }} | |
if git ls-remote --heads $JCB_REPO $BRANCH_NAME | grep -q "refs/heads/$BRANCH_NAME"; then | |
echo "Branch $BRANCH_NAME exists in jcb repo." | |
echo "JCB_BRANCH=$BRANCH_NAME" >> $GITHUB_ENV | |
else | |
echo "Branch $BRANCH_NAME does not exist in jcb repo. Using develop branch." | |
echo "JCB_BRANCH=develop" >> $GITHUB_ENV | |
fi | |
- name: Clone jcb repository | |
run: | | |
mkdir -p empty_hooks | |
git config --global core.hooksPath empty_hooks | |
git clone --branch ${{ env.JCB_BRANCH }} --recursive $JCB_REPO jcb_repo | |
- name: Clone the clients | |
run: | | |
cd jcb_repo | |
pip install pyyaml | |
./jcb_client_init.py | |
# If all the branches are found then at this point everything should be good since | |
# jcb_client_init will check out the correct branches. If not then the app branch needs to | |
# be checked out explicitly. | |
if [ "${{ env.JCB_BRANCH }}" != "${{ env.JCB_APP_BRANCH }}" ]; then | |
echo "Checking out branch ${{ env.JCB_APP_BRANCH }} for ${{ env.JCB_APP_REPO }}" | |
app_path=$(python jcb_client_path.py $JCB_APP_REPO) | |
cd $app_path | |
git checkout ${{ env.JCB_APP_BRANCH }} | |
fi | |
- name: Install dependencies | |
run: | | |
cd jcb_repo | |
pip install .[testing] | |
- name: Run the JCB client integration tests | |
run: | | |
cd jcb_repo/test/client_integration | |
pytest -v |