diff --git a/.coverage b/.coverage index 50511e1..ecda48d 100644 Binary files a/.coverage and b/.coverage differ diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..613e59a --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,120 @@ +name: CI + +on: + # push: -- just run on PRs for now + pull_request: + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + services: + postgres: + image: postgis/postgis:13-3.0 + env: + POSTGRES_PASSWORD: postgis + POSTGRES_DB: arches_rdm_example_project + 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"] + + 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: 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 arches_rdm_example_project/install/requirements.txt + pip install -r arches_rdm_example_project/install/requirements_dev.txt + echo Python packages installed + + - uses: ankane/setup-elasticsearch@v1 + with: + elasticsearch-version: 8 + + - 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 --pattern="*.py" --settings="tests.test_settings" + + - name: Report coverage + run: | + coverage report + coverage json + + - name: Upload coverage report as artifact + uses: actions/upload-artifact@v2 + with: + name: coverage-report + path: | + coverage.json + .coverage + + update-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: Retrieve baseline coverage + run: | + git fetch origin main:main + baseline_coverage=$(git show main:coverage.json | grep -o '"totals": {[^}]*' | grep -o '"percent_covered": [0-9.]*' | awk -F ': ' '{print $2}') + echo "$baseline_coverage" > .coverage_baseline + + - name: Download coverage report artifact + uses: actions/download-artifact@v2 + with: + name: coverage-report + path: . + + - 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 "$baseline_coverage% = $current_coverage%, Coverage didn't decrease. Committing new .coverage and coverage.json." + + git config user.name github-actions + git config user.email github-actions@github.com + + git add .coverage + git add coverage.json + + git commit -m "automatically update .coverage and coverage.json" + + git push -f origin HEAD:${{ github.event.pull_request.head.ref }} + fi diff --git a/.gitignore b/.gitignore index 793362b..c7a2c46 100644 --- a/.gitignore +++ b/.gitignore @@ -1,16 +1,17 @@ *.pyc *.log -*.DS_Store arches_rdm_example_project/logs arches_rdm_example_project/export_deliverables arches_rdm_example_project/cantaloupe/* arches_rdm_example_project/staticfiles arches_rdm_example_project/media/packages arches_rdm_example_project/media/node_modules -arches_rdm_example_project/media/build/* +arches_rdm_example_project/media/build/ arches_rdm_example_project/uploadedfiles/* arches_rdm_example_project/settings_local.py arches_rdm_example_project/webpack/webpack-stats.json arches_rdm_example_project/webpack/webpack-user-config.js .vscode/ +*.egg-info +.DS_STORE CACHE \ No newline at end of file diff --git a/arches_rdm_example_project/.eslintrc.js b/arches_rdm_example_project/.eslintrc.js index ef099d5..1e217ad 100644 --- a/arches_rdm_example_project/.eslintrc.js +++ b/arches_rdm_example_project/.eslintrc.js @@ -1,16 +1,23 @@ module.exports = { "extends": [ - "eslint:recommended" + "eslint:recommended", + 'plugin:@typescript-eslint/recommended', + 'plugin:vue/vue3-recommended', ], + "root": true, "env": { "browser": true, "es6": true, "node": true }, + "parser": "vue-eslint-parser", "parserOptions": { "ecmaVersion": 11, "sourceType": "module", - "requireConfigFile": false + "requireConfigFile": false, + "parser": { + "ts": "@typescript-eslint/parser" + } }, "globals": { "define": false, @@ -25,20 +32,33 @@ module.exports = { "URLSearchParams": false, "fetch": false }, - "ignorePatterns": [".eslintrc.js", "**/media/plugins/*"], "rules": { "semi": ["error", "always"], - "indent": ["error", 4], - "space-before-function-paren": ["error", "never"], - "no-extra-boolean-cast": 0, // 0=silence, 1=warning, 2=error - // allow async-await - 'generator-star-spacing': 'off', - // allow debugger during development - 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', - 'no-unused-vars': [1, { - argsIgnorePattern: '^_' - }], - "camelcase": [1, {"properties": "always"}], - } + }, + "overrides": [ + { + "files": [ "*.vue" ], + "rules": { + "vue/html-indent": [2, 4], + "vue/this-in-template": "off" + } + }, + { + "files": [ "*.js" ], + "rules": { + "indent": ["error", 4], + "space-before-function-paren": ["error", "never"], + "no-extra-boolean-cast": 0, // 0=silence, 1=warning, 2=error + // allow async-await + 'generator-star-spacing': 'off', + // allow debugger during development + 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', + 'no-unused-vars': [1, { + argsIgnorePattern: '^_' + }], + "camelcase": [1, {"properties": "always"}], + } + } + ] }; \ No newline at end of file diff --git a/arches_rdm_example_project/gettext.config.js b/arches_rdm_example_project/gettext.config.js new file mode 100644 index 0000000..3b3f4bd --- /dev/null +++ b/arches_rdm_example_project/gettext.config.js @@ -0,0 +1,43 @@ + +module.exports = { + input: { + path: "./src", // only files in this directory are considered for extraction + include: ["**/*.vue"], // glob patterns to select files for extraction + exclude: [], // glob patterns to exclude files from extraction + jsExtractorOpts:[ // custom extractor keyword. default empty. + { + keyword: "__", // only extractor default keyword such as $gettext,use keyword to custom + options: { // see https://github.com/lukasgeiter/gettext-extractor + content: { + replaceNewLines: "\n", + }, + arguments: { + text: 0, + }, + }, + }, + { + keyword: "_n", // $ngettext + options: { + content: { + replaceNewLines: "\n", + }, + arguments: { + text: 0, + textPlural: 1, + }, + }, + }, + ], + compileTemplate: false, // do not compile