From e3173375a1b123e20a387d6e4089b1100eb5bcee Mon Sep 17 00:00:00 2001 From: Joseph Rhoads Date: Mon, 27 Oct 2025 12:39:57 +0100 Subject: [PATCH] Refactor CI workflows to use reusable test configuration (#494) --- .github/dependabot.yml | 12 +++++ .github/workflows/dev.yml | 84 +---------------------------------- .github/workflows/release.yml | 72 +----------------------------- .github/workflows/staging.yml | 71 +---------------------------- 4 files changed, 18 insertions(+), 221 deletions(-) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..96b466b --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +version: 2 +updates: + - package-ecosystem: "pip" + directory: "/" + schedule: + interval: "weekly" + # Raise pull requests for version updates + # to pip against the `dev` branch + target-branch: "dev" + # Labels on pull requests for version updates only + labels: + - "pip dependencies" \ No newline at end of file diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 5f6383e..65dd657 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -8,89 +8,9 @@ on: - ./github/* jobs: test: - runs-on: ubuntu-latest - env: - ELASTIC7_HOST: "localhost" - ELASTIC7_PORT: "9200" - ELASTIC_PASSWORD: "changeme" - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_REGION: ${{ secrets.AWS_REGION }} - GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} - LAUNCH_DARKLY_KEY: ${{ secrets.LAUNCH_DARKLY_KEY_DEV }} - DB_HOST: 127.0.0.1 # Will not work with 'localhost', since that will try a Unix socket connection (!) - services: - elasticsearch7: - image: docker.elastic.co/elasticsearch/elasticsearch:7.10.0 - env: - discovery.type: single-node - ES_JAVA_OPTS: -Xms512m -Xmx512m - ELASTIC_PASSWORD: changeme - xpack.security.enabled: "false" - http.cors.enabled: "true" - http.cors.allow-origin: "*" - ports: - - 9200:9200 - db: - image: mysql:8.0 - env: - MYSQL_DATABASE: "rorapi" - MYSQL_USER: "ror_user" - MYSQL_PASSWORD: "password" - MYSQL_ROOT_PASSWORD: "password" - ports: - - 3306:3306 - options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 - steps: - - name: Checkout ror-api code - uses: actions/checkout@v2 - with: - path: ror-api - - name: Checkout ror-data-test - uses: actions/checkout@v2 - with: - repository: ror-community/ror-data-test - token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} - path: ror-data-test - - name: Get last data dump name - working-directory: ./ror-data-test - run: | - FILE="$(ls -Art *.zip | tail -n 1)" - echo ${FILE%.*} - echo "LATEST_DUMP_FILE=${FILE%.*}" >> $GITHUB_ENV - - name: Cache dependency - uses: actions/cache@v4 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pip- - - name: Set up Python environment - uses: actions/setup-python@v2 - with: - python-version: "3.8" - - name: Install requirements - working-directory: ./ror-api - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - pip install yapf + uses: ./.github/workflows/run_tests.yml + secrets: inherit - python manage.py collectstatic --noinput - - name: Setup - working-directory: ./ror-api - run: | - python manage.py setup v1.55-2024-10-31-ror-data -t - # Dump file temp hard coded for v2.1 release - # Pulled from ror-data-test per settings.py config - - name: Test - working-directory: ./ror-api - run: | - python manage.py test rorapi.tests.tests_unit - # python manage.py test rorapi.tests.tests_affiliations - # TODO fix these tests running in GitHub Action - # python manage.py test rorapi.tests_integration - # python manage.py test rorapi.tests_functional build: needs: test diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fede267..9df990e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,76 +4,8 @@ on: types: [published] jobs: test: - runs-on: ubuntu-latest - env: - ELASTIC_PASSWORD: "changeme" - ELASTIC7_HOST: "localhost" - ELASTIC7_PORT: "9200" - DB_HOST: 127.0.0.1 - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_REGION: ${{ secrets.AWS_REGION }} - GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} - LAUNCH_DARKLY_KEY: ${{ secrets.LAUNCH_DARKLY_KEY_PROD}} - services: - elasticsearch7: - image: docker.elastic.co/elasticsearch/elasticsearch:7.10.0 - env: - discovery.type: single-node - ES_JAVA_OPTS: -Xms512m -Xmx512m - ELASTIC_PASSWORD: changeme - xpack.security.enabled: "false" - http.cors.enabled: "true" - http.cors.allow-origin: "*" - ports: - - 9200:9200 - db: - image: mysql:8.0 - env: - MYSQL_DATABASE: "rorapi" - MYSQL_USER: "ror_user" - MYSQL_PASSWORD: "password" - MYSQL_ROOT_PASSWORD: "password" - ports: - - 3306:3306 - options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 - steps: - - name: Checkout ror-api code - uses: actions/checkout@v2 - with: - path: ror-api - - name: Cache dependency - uses: actions/cache@v4 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pip- - - name: Set up Python environment - uses: actions/setup-python@v2 - with: - python-version: "3.8" - - name: Install requirements - working-directory: ./ror-api - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - pip install yapf - - python manage.py collectstatic --noinput - - name: Setup - working-directory: ./ror-api - run: | - python manage.py setup v1.55-2024-10-31-ror-data -t - # temp hard-coded dump file for v2.1 release - - name: Test - working-directory: ./ror-api - run: | - python manage.py test rorapi.tests.tests_unit - # TODO fix these tests running in GitHub Action - # python manage.py test rorapi.tests_integration - # python manage.py test rorapi.tests_functional - + uses: ./.github/workflows/run_tests.yml + secrets: inherit build: needs: test runs-on: ubuntu-latest diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml index 42907f1..b764937 100644 --- a/.github/workflows/staging.yml +++ b/.github/workflows/staging.yml @@ -5,75 +5,8 @@ on: - "staging" jobs: test: - runs-on: ubuntu-latest - env: - ELASTIC_PASSWORD: "changeme" - ELASTIC7_HOST: "localhost" - ELASTIC7_PORT: "9200" - DB_HOST: 127.0.0.1 - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_REGION: ${{ secrets.AWS_REGION }} - GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} - LAUNCH_DARKLY_KEY: ${{ secrets.LAUNCH_DARKLY_KEY_STAGING }} - services: - elasticsearch7: - image: docker.elastic.co/elasticsearch/elasticsearch:7.10.0 - env: - discovery.type: single-node - ES_JAVA_OPTS: -Xms512m -Xmx512m - ELASTIC_PASSWORD: changeme - xpack.security.enabled: "false" - http.cors.enabled: "true" - http.cors.allow-origin: "*" - ports: - - 9200:9200 - db: - image: mysql:8.0 - env: - MYSQL_DATABASE: "rorapi" - MYSQL_USER: "ror_user" - MYSQL_PASSWORD: "password" - MYSQL_ROOT_PASSWORD: "password" - ports: - - 3306:3306 - options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 - steps: - - name: Checkout ror-api code - uses: actions/checkout@v2 - with: - path: ror-api - - name: Cache dependency - uses: actions/cache@v4 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pip- - - name: Set up Python environment - uses: actions/setup-python@v2 - with: - python-version: "3.8" - - name: Install requirements - working-directory: ./ror-api - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - pip install yapf - - python manage.py collectstatic --noinput - - name: Setup - working-directory: ./ror-api - run: | - python manage.py setup v1.55-2024-10-31-ror-data -t - # temp hard-coded dump file for v2.1 release - - name: Test - working-directory: ./ror-api - run: | - python manage.py test rorapi.tests.tests_unit - # TODO fix these tests running in GitHub Action - # python manage.py test rorapi.tests_integration - # python manage.py test rorapi.tests_functional + uses: ./.github/workflows/run_tests.yml + secrets: inherit build: needs: test