Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug action #31

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 2 additions & 23 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,29 +121,8 @@ jobs:
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 arches_lingo/install/requirements.txt
pip install -r arches_lingo/install/requirements_dev.txt
echo Python packages installed

- uses: ankane/setup-elasticsearch@v1
with:
elasticsearch-version: 8
- name: Debug npm cache
run: npm ls eslint-config-prettier && npm clear cache && npm run install && npm ls eslint-config-prettier

- name: Webpack frontend files
run: |
Expand Down
30 changes: 30 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
repos:

- repo: https://github.com/psf/black
rev: 24.4.2
hooks:
- id: black
args: [--quiet]
exclude: node_modules

- repo: local
hooks:
- id: prettier
name: prettier
entry: npm run prettier:fix
language: system
files: arches_lingo/src
- id: eslint
name: eslint
entry: npm run eslint:fix
language: system
files: arches_lingo/src
- id: typescript
name: typescript
entry: npm run ts:check
language: system
types: [
"ts",
"vue",
]
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"singleAttributePerLine": true
}
Empty file.
5 changes: 3 additions & 2 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
import js from "@eslint/js";
import pluginVue from 'eslint-plugin-vue';
import tseslint from 'typescript-eslint';
import eslintConfigPrettier from "eslint-config-prettier";

import vueESLintParser from 'vue-eslint-parser';

export default [
js.configs.recommended,
...pluginVue.configs['flat/recommended'],
...tseslint.configs.recommended,
eslintConfigPrettier,
{
"languageOptions": {
"globals": {
Expand Down Expand Up @@ -36,7 +38,6 @@ export default [
},
"rules": {
"semi": ["error", "always"],
"vue/html-indent": ["error", 4]
},
},
]
];
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"eslint:watch": "nodemon --watch . --ext ts,vue --exec npm run --silent eslint:check",
"gettext:extract": "vue-gettext-extract",
"gettext:compile": "vue-gettext-compile",
"prettier:check": "prettier arches_lingo/src --check",
"prettier:fix": "prettier arches_lingo/src --write",
"ts:check": "vue-tsc --noEmit",
"ts:watch": "vue-tsc --watch --noEmit",
"start": "cross-env NODE_OPTIONS=--max-old-space-size=2048 webpack serve --config ./webpack/webpack.config.dev.js",
Expand Down
8 changes: 6 additions & 2 deletions webpack/webpack-utils/find-file.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
const fs = require('fs');
const Path = require('path');

function findFile(path, target) {
function findFile(path, target, excludedDirectories) {
if (!excludedDirectories) {
excludedDirectories = [];
}

for (const name of fs.readdirSync(path)) {
const filePath = Path.join(path, name);
const stat = fs.lstatSync(filePath);

if (stat.isDirectory() && name !== 'node_modules') {
if (stat.isDirectory() && !excludedDirectories.includes(name)) {
const result = findFile(filePath, target);
if (result) {
return result;
Expand Down
44 changes: 27 additions & 17 deletions webpack/webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,12 @@ module.exports = () => {
if (serverAddress.charAt(serverAddress.length - 1) === '/') {
serverAddress = serverAddress.slice(0, -1)
}

resp = await fetch(serverAddress + templatePath);

if (resp.status === 500) {
throw new Error();
}
}
catch (e) {
failureCount += 1;
Expand All @@ -447,22 +452,27 @@ module.exports = () => {
}
}
else {
console.error(
'\x1b[31m%s\x1b[0m', // red
`"${templatePath}" has failed to load! Falling back to un-rendered file.`
);
resp = {
text: () => (
new Promise((resolve, _reject) => {
/*
if run in a test environment, failures will return a empty string which will
still allow the bundle to build.
*/

resolve(isTestEnvironment ? '' : content);
})
)
};
if (!isTestEnvironment) {
loaderContext.emitError(`Unable to fetch ${templatePath} from the Django server.`)
}
else {
console.warn(
'\x1b[31m%s\x1b[0m', // red
`"${templatePath}" has failed to load! Test environment detected, falling back to un-rendered file.`
);
resp = {
text: () => (
new Promise((resolve, _reject) => {
/*
if run in a test environment, failures will return a empty string which will
still allow the bundle to build.
*/

resolve(isTestEnvironment ? '' : content);
})
)
};
}
}
};

Expand All @@ -489,7 +499,7 @@ module.exports = () => {
};

// BEGIN get data from `settings.py`
const settingsFilePath = findFile(Path.dirname(__dirname), 'settings.py')
const settingsFilePath = findFile(Path.dirname(__dirname), 'settings.py', ["node_modules", "build"]);

const runPythonScript = (pythonCommand) => {
let projectSettings = spawn(pythonCommand, [settingsFilePath]);
Expand Down
Loading