ci: exec build & cargo test only for now
This commit is contained in:
parent
c8372767fa
commit
442dc33a34
1 changed files with 10 additions and 69 deletions
|
@ -19,7 +19,7 @@ cache:
|
||||||
- target/
|
- target/
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- auto_update
|
- test
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
POSTGRES_DB: firefish_db
|
POSTGRES_DB: firefish_db
|
||||||
|
@ -38,73 +38,14 @@ default:
|
||||||
- export PGPASSWORD="${POSTGRES_PASSWORD}"
|
- export PGPASSWORD="${POSTGRES_PASSWORD}"
|
||||||
- psql --host postgres --user "${POSTGRES_USER}" --dbname "${POSTGRES_DB}" --command 'CREATE EXTENSION pgroonga'
|
- psql --host postgres --user "${POSTGRES_USER}" --dbname "${POSTGRES_DB}" --command 'CREATE EXTENSION pgroonga'
|
||||||
|
|
||||||
auto_update:
|
build_test:
|
||||||
stage: auto_update
|
stage: test
|
||||||
script:
|
script:
|
||||||
# setup git
|
- pnpm install --frozen-lockfile
|
||||||
- apk add git
|
|
||||||
- git config user.name 'GitLab CI'
|
|
||||||
- git config user.email 'noreply@firefish.dev'
|
|
||||||
- git remote set-url origin "https://${CI_REGISTRY_USER}:${API_TOKEN}@${CI_REPOSITORY_URL#*@}"
|
|
||||||
# update pnpm lockfile
|
|
||||||
- pnpm install
|
|
||||||
# commit
|
|
||||||
- |-
|
|
||||||
if [ `git status -s | wc -l` -gt 0 ]; then
|
|
||||||
git add .
|
|
||||||
git commit --message 'chore: update lockfile'
|
|
||||||
git push --push-option=ci.skip origin "${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME}"
|
|
||||||
fi
|
|
||||||
# run format
|
|
||||||
- pnpm run format
|
|
||||||
# commit
|
|
||||||
- |-
|
|
||||||
if [ `git status -s | wc -l` -gt 0 ]; then
|
|
||||||
git add .
|
|
||||||
git commit --message 'chore: format'
|
|
||||||
git push --push-option=ci.skip origin "${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME}"
|
|
||||||
fi
|
|
||||||
# update packages/backend-rs/src/model/entity
|
|
||||||
- apk install pkgconfig openssl openssl-dev libssl3
|
|
||||||
- cargo install sea-orm-cli
|
|
||||||
- pnpm --filter backend run build:debug
|
|
||||||
- pnpm run migrate
|
|
||||||
- cd packages/backend-rs
|
|
||||||
- mv src/model/entity src/model/entity.bak
|
|
||||||
- |-
|
|
||||||
sea-orm-cli generate entity \
|
|
||||||
--output-dir='src/model/entity' \
|
|
||||||
--date-time-crate='chrono' \
|
|
||||||
--model-extra-attributes='NAPI_EXTRA_ATTR_PLACEHOLDER' \
|
|
||||||
--database-url="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}"
|
|
||||||
- |-
|
|
||||||
for file in src/model/entity/*; do
|
|
||||||
base=$(basename -- "${file}")
|
|
||||||
jsname=$(printf '%s\n' "${base%.*}" | perl -pe 's/(^|_)./uc($&)/ge;s/_//g')
|
|
||||||
attribute=$(printf 'cfg_attr(feature = "napi", napi_derive::napi(object, js_name = "%s", use_nullable = true))' "${jsname}")
|
|
||||||
sed -i "s/NAPI_EXTRA_ATTR_PLACEHOLDER/${attribute}/" "${file}"
|
|
||||||
sed -i 's/#\[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)\]/#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, serde::Serialize, serde::Deserialize)]\n#[serde(rename_all = "camelCase")]/' "${file}"
|
|
||||||
done
|
|
||||||
- |-
|
|
||||||
sed -i 's/#\[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)\]/#[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum, serde::Serialize, serde::Deserialize)]\n#[serde(rename_all = "camelCase")]\n#[cfg_attr(not(feature = "napi"), derive(Clone))]\n#[cfg_attr(feature = "napi", napi_derive::napi(string_enum = "camelCase"))]/' \
|
|
||||||
src/model/entity/sea_orm_active_enums.rs
|
|
||||||
- rm --recursive --force src/model/entity.bak
|
|
||||||
- cargo fmt --all --
|
|
||||||
# commit
|
|
||||||
- |-
|
|
||||||
if [ `git status -s | wc -l` -gt 0 ]; then
|
|
||||||
git add .
|
|
||||||
git commit --message 'chore (backend-rs): regenerate entity'
|
|
||||||
git push --push-option=ci.skip origin "${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME}"
|
|
||||||
fi
|
|
||||||
# update packages/backend-rs/index.{js,d.ts}
|
|
||||||
- pnpm run build:debug
|
- pnpm run build:debug
|
||||||
- /bin/cp --force built/index.js index.js
|
- pnpm run migrate
|
||||||
- /bin/cp --force built/index.d.ts index.d.ts
|
|
||||||
- sed -i 's/^ \*r"/ */g' index.d.ts
|
cargo_test:
|
||||||
- |-
|
stage: test
|
||||||
if [ `git status -s | wc -l` -gt 0 ]; then
|
script:
|
||||||
git add .
|
- cargo test
|
||||||
git commit --message 'chore (backend-rs): regenerate index'
|
|
||||||
git push --push-option=ci.skip origin "${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME}"
|
|
||||||
fi
|
|
||||||
|
|
Loading…
Reference in a new issue