diff --git a/.github/workflows/check-base-branch-before-merge.yml b/.github/workflows/check-base-branch-before-merge.yml deleted file mode 100644 index ba72dcf..0000000 --- a/.github/workflows/check-base-branch-before-merge.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Check Base Branch Before Merge - -on: - pull_request_review: - types: [submitted] - -jobs: - check-base-branch-before-merge: - if: github.event.review.state == 'APPROVED' - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Check base branch - run: | - git fetch origin --prune - - CURRENT_BRANCH=${{ github.event.pull_request.head.ref }} - TARGET_BRANCH="${{ github.event.pull_request.base.ref }}" - - COMMON_ANCESTOR=$(git merge-base origin/$CURRENT_BRANCH origin/$TARGET_BRANCH) - COMMITS_BEHIND=$(git rev-list --count origin/$TARGET_BRANCH ^$COMMON_ANCESTOR) - - if [ "$COMMITS_BEHIND" -eq 0 ]; then - echo "Your branch is up-to-date with the target branch." - elif [ "$COMMITS_BEHIND" -eq 1 ]; then - echo "Your branch is 1 commit behind the target branch." - exit 1 - else - echo "Your branch is $COMMITS_BEHIND commits behind the target branch." - exit 1 - fi diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 173205e..39645f9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,13 +8,12 @@ on: jobs: build: runs-on: ubuntu-latest - services: postgres: image: postgis/postgis:13-3.0 env: POSTGRES_PASSWORD: postgis - POSTGRES_DB: ${{ github.event.repository.name }} + POSTGRES_DB: arches ports: - 5432:5432 options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 @@ -22,12 +21,10 @@ jobs: strategy: fail-fast: false matrix: - # python-version: ["3.10", "3.11", "3.12"] - python-version: ["3.12"] + python-version: ["3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: @@ -44,164 +41,30 @@ jobs: run: | python -m pip install --upgrade pip pip install . - pip install -r ${{ github.event.repository.name }}/install/requirements.txt - pip install -r ${{ github.event.repository.name }}/install/requirements_dev.txt + pip install -r arches/install/requirements.txt + pip install -r arches/install/requirements_dev.txt echo Python packages installed + - uses: ankane/setup-elasticsearch@v1 with: elasticsearch-version: 8 - # - name: Webpack frontend files - # run: | - # echo "Removing yarn.lock due to yarn v1 package resolution issues" - # echo "https://github.com/iarna/wide-align/issues/63" - # rm yarn.lock - # yarn && yarn build_test + - name: Webpack frontend files + run: | + echo "Removing yarn.lock due to yarn v1 package resolution issues" + echo "https://github.com/iarna/wide-align/issues/63" + rm yarn.lock + yarn && yarn build_test - name: Check for missing migrations run: | python manage.py makemigrations --check - - name: Ensure previous coverage data is erased - run: | - coverage erase - - - name: Run unit tests + - name: Run Arches unit tests run: | python -W default::DeprecationWarning -m coverage run manage.py test tests --settings="tests.test_settings" - - name: Generate report coverage + - name: Report coverage run: | - coverage json - cat coverage.json - - - name: Upload coverage report as artifact - uses: actions/upload-artifact@v4 - with: - name: current-coverage-report - path: coverage.json - overwrite: true - - check_target_branch_coverage: - runs-on: ubuntu-latest - - services: - postgres: - image: postgis/postgis:13-3.0 - env: - POSTGRES_PASSWORD: postgis - POSTGRES_DB: ${{ github.event.repository.name }} - ports: - - 5432:5432 - options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 - - strategy: - fail-fast: false - matrix: - # python-version: ["3.10", "3.11", "3.12"] - python-version: ["3.12"] - - steps: - - uses: actions/checkout@v4 - with: - ref: ${{ github.event.pull_request.base.ref }} - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - check-latest: true - - - name: Install Java, GDAL, and other system dependencies - run: | - sudo apt update - sudo apt-get install libxml2-dev libpq-dev openjdk-8-jdk libgdal-dev libxslt-dev - echo Postgres and ES dependencies installed - - - name: Install python packages - run: | - python -m pip install --upgrade pip - pip install . - pip install -r ${{ github.event.repository.name }}/install/requirements.txt - pip install -r ${{ github.event.repository.name }}/install/requirements_dev.txt - echo Python packages installed - - - uses: ankane/setup-elasticsearch@v1 - with: - elasticsearch-version: 8 - - - name: Ensure previous coverage data is erased - run: | - coverage erase - - - name: Run unit tests - run: | - python -W default::DeprecationWarning -m coverage run manage.py test tests --settings="tests.test_settings" - - - name: Generate report coverage - run: | - coverage json - cat coverage.json - - - name: Upload coverage report as artifact - uses: actions/upload-artifact@v4 - with: - name: target-coverage-report - path: coverage.json - overwrite: true - - # check-coverage: - # runs-on: ubuntu-latest - # needs: [build] - # steps: - # - uses: actions/checkout@v4 - - # - name: Set up Python - # uses: actions/setup-python@v5 - # with: - # python-version: '3.x' # Use the latest available version - # check-latest: true - - # - name: Download coverage report artifact - # uses: actions/download-artifact@v4 - # with: - # name: coverage-report - # path: . - - # - name: Report coverage - # run: | - # cat coverage.json - - # - name: Retrieve baseline coverage - # run: | - # git fetch origin ${{ github.event.pull_request.base.ref }}:${{ github.event.pull_request.base.ref }} - - # if ! git show ${{ github.event.pull_request.base.ref }}:coverage.json > /dev/null; then - # echo "Error: coverage.json does not exist in the branch." - # exit 1 - # fi - - # baseline_coverage=$(git show ${{ github.event.pull_request.base.ref }}:coverage.json | grep -o '"totals": {[^}]*' | grep -o '"percent_covered": [0-9.]*' | awk -F ': ' '{print $2}') - # echo "$baseline_coverage" > .coverage_baseline - - # - name: Compare coverage with baseline - # if: github.event_name == 'pull_request' - # run: | - # current_coverage=$(cat coverage.json | grep -o '"totals": {[^}]*' | grep -o '"percent_covered": [0-9.]*' | awk -F ': ' '{print $2}') - # baseline_coverage=$(cat .coverage_baseline) - - # # Compare current coverage with baseline coverage using floating-point comparison - # if awk -v current="$current_coverage" -v baseline="$baseline_coverage" 'BEGIN { exit (current < baseline) ? 0 : 1 }'; then - # echo "Coverage decreased from $baseline_coverage% to $current_coverage%" - # exit 1 - # else - # echo "Current branch coverage ($current_coverage%) >= Target branch coverage ($baseline_coverage%). Committing new coverage.json." - - # git config user.name github-actions - # git config user.email github-actions@github.com - - # git add -f coverage.json - # git commit -m "automatically update coverage.json" - # git push -f origin HEAD:${{ github.head_ref }} - # fi + coverage report diff --git a/.github/workflows/update-test-coverage-artifact.yml b/.github/workflows/update-test-coverage-artifact.yml deleted file mode 100644 index 04bc57a..0000000 --- a/.github/workflows/update-test-coverage-artifact.yml +++ /dev/null @@ -1,95 +0,0 @@ -name: Update Test Coverage Artifact - -on: - workflow_dispatch: - inputs: - isManual: - description: 'Manual Run?' - required: true - default: true - type: boolean - pull_request: - types: - - closed - -jobs: - update-test-coverage-artifact: - # if: github.event.pull_request.merged == true || ${{ inputs.isManual }} == true - runs-on: ubuntu-latest - - services: - postgres: - image: postgis/postgis:13-3.0 - env: - POSTGRES_PASSWORD: postgis - POSTGRES_DB: ${{ github.event.repository.name }} - ports: - - 5432:5432 - options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 - - strategy: - fail-fast: false - matrix: - python-version: ["3.12"] - - steps: - - uses: actions/checkout@v4 - - - uses: geekyeggo/delete-artifact@v5 - with: - name: ${{ github.event.pull_request.base.ref }}-coverage-report - failOnError: false - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - check-latest: true - - - name: Install Java, GDAL, and other system dependencies - run: | - sudo apt update - sudo apt-get install libxml2-dev libpq-dev openjdk-8-jdk libgdal-dev libxslt-dev - echo Postgres and ES dependencies installed - - - name: Install python packages - run: | - python -m pip install --upgrade pip - pip install . - pip install -r ${{ github.event.repository.name }}/install/requirements.txt - pip install -r ${{ github.event.repository.name }}/install/requirements_dev.txt - echo Python packages installed - - - uses: ankane/setup-elasticsearch@v1 - with: - elasticsearch-version: 8 - - # - name: Webpack frontend files - # run: | - # echo "Removing yarn.lock due to yarn v1 package resolution issues" - # echo "https://github.com/iarna/wide-align/issues/63" - # rm yarn.lock - # yarn && yarn build_test - - - name: Check for missing migrations - run: | - python manage.py makemigrations --check - - - name: Run unit tests - run: | - python -W default::DeprecationWarning -m coverage run manage.py test tests --settings="tests.test_settings" - - - name: Generate report coverage - run: | - coverage json - - - name: Upload coverage report as artifact - uses: actions/upload-artifact@v4 - with: - name: ${{ github.event.pull_request.base.ref }}-coverage-report - path: coverage.json - - - uses: geekyeggo/delete-artifact@v5 - with: - name: ${{ github.event.pull_request.head.ref }}-coverage-report - \ No newline at end of file