-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update apps.py and gh actions for 7.6 latest
- Loading branch information
Showing
3 changed files
with
247 additions
and
58 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,272 @@ | ||
name: CI | ||
|
||
on: | ||
on: | ||
# push: -- just run on PRs for now | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
build_target_branch: | ||
runs-on: ubuntu-latest | ||
|
||
services: | ||
postgres: | ||
image: postgis/postgis:13-3.0 | ||
env: | ||
POSTGRES_PASSWORD: postgis | ||
POSTGRES_DB: arches | ||
POSTGRES_DB: arches_for_science | ||
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: | ||
- name: Check out arches | ||
uses: actions/checkout@v3 | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
repository: archesproject/arches | ||
ref: dev/7.6.x | ||
path: arches | ||
python-version: ${{ matrix.python-version }} | ||
check-latest: true | ||
|
||
- name: Check out afs | ||
uses: actions/checkout@v2 | ||
- name: Checkout into target branch | ||
uses: actions/checkout@v4 | ||
with: | ||
path: afs | ||
repository: ${{ github.repository }} | ||
ref: ${{ github.event.pull_request.base.ref }} | ||
path: . | ||
|
||
- name: Set up Python 3.10 | ||
uses: actions/setup-python@v4 | ||
- name: Build and test branch | ||
uses: ./.github/actions/build-and-test-branch | ||
with: | ||
python-version: '3.10' | ||
secrets: ${{ toJSON(secrets) }} | ||
project-name: 'arches_for_science' | ||
branch-type: 'target' | ||
|
||
- name: Install afs | ||
working-directory: afs | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install . | ||
echo Project installed | ||
build_feature_branch: | ||
runs-on: ubuntu-latest | ||
|
||
- name: Install arches dev version | ||
working-directory: arches | ||
run: | | ||
python -m pip uninstall arches -y | ||
python -m pip install . | ||
echo Arches dev version installed | ||
services: | ||
postgres: | ||
image: postgis/postgis:13-3.0 | ||
env: | ||
POSTGRES_PASSWORD: postgis | ||
POSTGRES_DB: arches_for_science | ||
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"] | ||
|
||
- name: Install Java, GDAL, and other system dependencies | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
check-latest: true | ||
|
||
- name: Checkout into feature branch | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: ${{ github.repository }} | ||
ref: ${{ github.ref }} | ||
path: . | ||
|
||
- name: Build and test branch | ||
uses: ./.github/actions/build-and-test-branch | ||
with: | ||
secrets: ${{ toJSON(secrets) }} | ||
project-name: 'arches_for_science' | ||
branch-type: 'feature' | ||
|
||
check_frontend_coverage: | ||
runs-on: ubuntu-latest | ||
needs: [build_feature_branch, build_target_branch] | ||
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 feature branch frontend coverage report artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: feature-branch-frontend-coverage-report | ||
path: . | ||
|
||
- name: Extract feature branch frontend coverage data | ||
shell: pwsh | ||
run: | | ||
sudo apt update | ||
sudo apt-get install libxml2-dev libpq-dev openjdk-8-jdk libgdal-dev | ||
echo Postgres and ES dependencies installed | ||
[xml]$xml = Get-Content feature_branch_frontend_coverage.xml | ||
$metrics = $xml.coverage.project.metrics | ||
$statements = [double]$metrics.statements | ||
$coveredstatements = [double]$metrics.coveredstatements | ||
$conditionals = [double]$metrics.conditionals | ||
$coveredconditionals = [double]$metrics.coveredconditionals | ||
$methods = [double]$metrics.methods | ||
$coveredmethods = [double]$metrics.coveredmethods | ||
$elements = [double]$metrics.elements | ||
$coveredelements = [double]$metrics.coveredelements | ||
$statement_coverage = 0.0 | ||
$conditional_coverage = 0.0 | ||
$method_coverage = 0.0 | ||
$element_coverage = 0.0 | ||
if ($statements -gt 0) { | ||
$statement_coverage = ($coveredstatements / $statements) * 100 | ||
} | ||
if ($conditionals -gt 0) { | ||
$conditional_coverage = ($coveredconditionals / $conditionals) * 100 | ||
} | ||
if ($methods -gt 0) { | ||
$method_coverage = ($coveredmethods / $methods) * 100 | ||
} | ||
if ($elements -gt 0) { | ||
$element_coverage = ($coveredelements / $elements) * 100 | ||
} | ||
$nonZeroCount = 0 | ||
$totalCoverage = 0.0 | ||
if ($statements -gt 0) { $nonZeroCount++; $totalCoverage += $statement_coverage } | ||
if ($conditionals -gt 0) { $nonZeroCount++; $totalCoverage += $conditional_coverage } | ||
if ($methods -gt 0) { $nonZeroCount++; $totalCoverage += $method_coverage } | ||
if ($elements -gt 0) { $nonZeroCount++; $totalCoverage += $element_coverage } | ||
$feature_branch_frontend_coverage = 0.0 | ||
if ($nonZeroCount -gt 0) { | ||
$feature_branch_frontend_coverage = $totalCoverage / $nonZeroCount | ||
} | ||
- uses: ankane/setup-elasticsearch@v1 | ||
Write-Output "feature_branch_frontend_coverage=$feature_branch_frontend_coverage" | Out-File -Append $env:GITHUB_ENV | ||
- name: Download target branch frontend coverage report artifact | ||
continue-on-error: true | ||
uses: actions/download-artifact@v4 | ||
with: | ||
elasticsearch-version: 8 | ||
name: target-branch-frontend-coverage-report | ||
path: . | ||
|
||
- name: Check if target branch frontend coverage report artifact exists | ||
run: | | ||
if [ -f target_branch_frontend_coverage.xml ]; then | ||
echo "target_branch_frontend_coverage_artifact_exists=true" >> $GITHUB_ENV | ||
else | ||
echo "Target branch coverage not found. Defaulting to 0% coverage." | ||
echo "target_branch_frontend_coverage_artifact_exists=false" >> $GITHUB_ENV | ||
fi | ||
- name: Check for missing migrations | ||
working-directory: afs | ||
- name: Extract target branch frontend coverage data | ||
if: ${{ env.target_branch_frontend_coverage_artifact_exists == 'true' }} | ||
shell: pwsh | ||
run: | | ||
python manage.py makemigrations --check | ||
[xml]$xml = Get-Content target_branch_frontend_coverage.xml | ||
$metrics = $xml.coverage.project.metrics | ||
$statements = [double]$metrics.statements | ||
$coveredstatements = [double]$metrics.coveredstatements | ||
$conditionals = [double]$metrics.conditionals | ||
$coveredconditionals = [double]$metrics.coveredconditionals | ||
$methods = [double]$metrics.methods | ||
$coveredmethods = [double]$metrics.coveredmethods | ||
$elements = [double]$metrics.elements | ||
$coveredelements = [double]$metrics.coveredelements | ||
$statement_coverage = 0.0 | ||
$conditional_coverage = 0.0 | ||
$method_coverage = 0.0 | ||
$element_coverage = 0.0 | ||
if ($statements -gt 0) { | ||
$statement_coverage = ($coveredstatements / $statements) * 100 | ||
} | ||
if ($conditionals -gt 0) { | ||
$conditional_coverage = ($coveredconditionals / $conditionals) * 100 | ||
} | ||
if ($methods -gt 0) { | ||
$method_coverage = ($coveredmethods / $methods) * 100 | ||
} | ||
if ($elements -gt 0) { | ||
$element_coverage = ($coveredelements / $elements) * 100 | ||
} | ||
$nonZeroCount = 0 | ||
$totalCoverage = 0.0 | ||
- name: Lint backend | ||
working-directory: afs | ||
if ($statements -gt 0) { $nonZeroCount++; $totalCoverage += $statement_coverage } | ||
if ($conditionals -gt 0) { $nonZeroCount++; $totalCoverage += $conditional_coverage } | ||
if ($methods -gt 0) { $nonZeroCount++; $totalCoverage += $method_coverage } | ||
if ($elements -gt 0) { $nonZeroCount++; $totalCoverage += $element_coverage } | ||
$target_branch_frontend_coverage = 0.0 | ||
if ($nonZeroCount -gt 0) { | ||
$target_branch_frontend_coverage = $totalCoverage / $nonZeroCount | ||
} | ||
Write-Output "target_branch_frontend_coverage=$target_branch_frontend_coverage" | Out-File -Append $env:GITHUB_ENV | ||
- name: Compare frontend feature coverage with target coverage | ||
if: github.event_name == 'pull_request' | ||
run: | | ||
python -m pip install pylint | ||
PYTHONPATH="../arches" pylint arches_for_science --errors-only | ||
feature_branch_frontend_coverage=${feature_branch_frontend_coverage} | ||
target_branch_frontend_coverage=${target_branch_frontend_coverage:-0.0} | ||
# Compare feature coverage with target coverage using floating-point comparison | ||
if awk -v feature="$feature_branch_frontend_coverage" -v target="$target_branch_frontend_coverage" 'BEGIN { exit (feature < target) ? 0 : 1 }'; then | ||
echo "Coverage decreased from $target_branch_frontend_coverage% to $feature_branch_frontend_coverage%. Please add or update tests to increase coverage." | ||
exit 1 | ||
else | ||
echo "Feature branch coverage ($feature_branch_frontend_coverage%) >= Target branch coverage ($target_branch_frontend_coverage%)." | ||
fi | ||
check_python_coverage: | ||
runs-on: ubuntu-latest | ||
needs: [build_feature_branch, build_target_branch] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Run afs unit tests | ||
working-directory: afs | ||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.x' # Use the latest available version | ||
check-latest: true | ||
|
||
- name: Download feature branch Python coverage report artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: feature-branch-python-coverage-report | ||
path: . | ||
|
||
- name: Download target branch Python coverage report artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: target-branch-python-coverage-report | ||
path: . | ||
|
||
- name: Compare Python feature coverage with target coverage | ||
if: github.event_name == 'pull_request' | ||
run: | | ||
python -W default::DeprecationWarning manage.py test tests --settings=tests.test_settings | ||
feature_branch_python_coverage=$(cat feature_branch_python_coverage.json | grep -o '"totals": {[^}]*' | grep -o '"percent_covered": [0-9.]*' | awk -F ': ' '{print $2}') | ||
target_branch_python_coverage=$(cat target_branch_python_coverage.json | grep -o '"totals": {[^}]*' | grep -o '"percent_covered": [0-9.]*' | awk -F ': ' '{print $2}') | ||
# Compare feature coverage with target coverage using floating-point comparison | ||
if awk -v feature="$feature_branch_python_coverage" -v target="$target_branch_python_coverage" 'BEGIN { exit (feature < target) ? 0 : 1 }'; then | ||
echo "Coverage decreased from $target_branch_python_coverage% to $feature_branch_python_coverage%. Please add or update tests to increase coverage." | ||
exit 1 | ||
else | ||
echo "Feature branch coverage ($feature_branch_python_coverage%) >= Target branch coverage ($target_branch_python_coverage%)." | ||
fi |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
from django.apps import AppConfig | ||
|
||
from arches.settings_utils import generate_frontend_configuration | ||
|
||
|
||
class ArchesForScienceConfig(AppConfig): | ||
name = "arches_for_science" | ||
verbose_name = "Arches for Science" | ||
is_arches_application = True | ||
|
||
def ready(self): | ||
generate_frontend_configuration() |