Skip to content

Commit

Permalink
CI/CD: Config and keep remote files (#988)
Browse files Browse the repository at this point in the history
* Don't delete other files on remote machine

Previous behavior removed all files, except those excluded, from the remote directory

* Required for RedM natives update.

* Central config file for both native and compatgen

This allows us to easily change input and output file names throughout the whole native generation process.
  • Loading branch information
thorium-cfx authored Feb 14, 2024
1 parent d85bb74 commit f1f7a7d
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 16 deletions.
Empty file modified .ci/common.sh
100644 → 100755
Empty file.
4 changes: 4 additions & 0 deletions .ci/config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# default config values for our scripts. May be overriden in scripts, e.g.: manual workflow dispatch
CONFIG_UPLOAD_COMPAT_FILE="natives_global_client_compat"
CONFIG_UPLOAD_NATIVES_FILE="natives"
CONFIG_COMPAT_FROM_DATE="2023-01-01" #YYYY-MM-DD
9 changes: 6 additions & 3 deletions .ci/run-compat
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
#!/bin/bash

# configuration
ci_root="$(dirname "$0")"
. "$ci_root"/config.sh

GENERATOR_PATH="$1/compatgen.js"
OUTPUT_FILE=${2:-"./out/natives_global_client_compat.lua"}
INPUT_FILE=${3:-"./in/natives_global_client_compat.lua"}
OUTPUT_FILE=${2:-"./out/$CONFIG_UPLOAD_COMPAT_FILE.lua"}
INPUT_FILE=${3:-"./in/$CONFIG_UPLOAD_COMPAT_FILE.lua"}
IGNORE_MISSING_INPUT=${4:-false}
FORCE_UPDATE=${5:-false}
USE_HISTORY=${6:-false}
DAYS_SINCE_DATE=${7:-2023-01-01} #YYYY-MM-DD
DAYS_SINCE_DATE=${7:-"$CONFIG_COMPAT_FROM_DATE"} #YYYY-MM-DD
VERSION=${8:-2.0}

# execution
Expand Down
9 changes: 5 additions & 4 deletions .ci/run-deploy
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ ci_root="$(dirname "$0")"

# include common script
. "$ci_root"/common.sh
. "$ci_root"/config.sh

title "Building new documentation output...\n"

Expand All @@ -15,10 +16,10 @@ mkdir -p out
# Native generation
pushd "$BUILDER_ROOT"
node index.js "$repo_root"
cp -a natives_test.json "$repo_root/out/natives.json"
node build-template.js lua > "$repo_root/out/natives.lua"
node build-template.js reference > "$repo_root/out/natives.html"
cp -a natives_test.json "$repo_root/out/$CONFIG_UPLOAD_NATIVES_FILE.json"
node build-template.js lua > "$repo_root/out/$CONFIG_UPLOAD_NATIVES_FILE.lua"
node build-template.js reference > "$repo_root/out/$CONFIG_UPLOAD_NATIVES_FILE.html"
popd

# Compatibility native generation
"$ci_root"/run-compat "$BUILDER_ROOT" "./out/natives_global_client_compat.lua" "./in/natives_global_client_compat.lua"
"$ci_root"/run-compat "$BUILDER_ROOT" "./out/$CONFIG_UPLOAD_COMPAT_FILE.lua" "./in/$CONFIG_UPLOAD_COMPAT_FILE.lua"
Empty file modified .ci/run-pr
100644 → 100755
Empty file.
Empty file modified .ci/setup-builder
100644 → 100755
Empty file.
6 changes: 4 additions & 2 deletions .github/workflows/deploy-repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
push:
branches:
- master
workflow_dispatch:

jobs:
deploy:
Expand All @@ -26,7 +27,8 @@ jobs:
NATIVE_DEPLOY_URL: ${{ secrets.NATIVE_DEPLOY_URL }}
run: |
mkdir ./in
rsync -q --ignore-missing-args $NATIVE_DEPLOY_URL/natives_global_client_compat.lua ./in/natives_global_client_compat.lua
. ./.ci/config.sh
rsync -q --ignore-missing-args $NATIVE_DEPLOY_URL/$CONFIG_UPLOAD_COMPAT_FILE.lua ./in/$CONFIG_UPLOAD_COMPAT_FILE.lua
- name: Run build
run: |
set -xe
Expand All @@ -36,5 +38,5 @@ jobs:
env:
NATIVE_DEPLOY_URL: ${{ secrets.NATIVE_DEPLOY_URL }}
run: |
rsync -rq --delete-after --exclude=*compat.lua* ./out/ $NATIVE_DEPLOY_URL
rsync -rq --exclude=*compat.lua* ./out/ $NATIVE_DEPLOY_URL
rsync -rqb --backup-dir=./ --suffix=.bak --include=*compat.lua --exclude=* ./out/ $NATIVE_DEPLOY_URL
17 changes: 10 additions & 7 deletions .github/workflows/run-compatgen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,27 +60,32 @@ jobs:
env:
NATIVE_DEPLOY_URL: ${{ secrets.NATIVE_DEPLOY_URL }}
run: |
. ./.ci/config.sh
mkdir ./in
rsync -q --ignore-missing-args $NATIVE_DEPLOY_URL/natives_global_client_compat.lua ./in/natives_global_client_compat.lua
rsync -q --ignore-missing-args $NATIVE_DEPLOY_URL/$CONFIG_UPLOAD_COMPAT_FILE.lua ./in/$CONFIG_UPLOAD_COMPAT_FILE.lua
- name: Run build
shell: bash
run: |
set -xe
. ./.ci/config.sh
git fetch origin $GITHUB_REF_NAME --shallow-since=${{ inputs.since_date }}
pushd ./
. ./.ci/setup-builder
popd
mkdir -p out
[ ${{ inputs.no_input }} == false ] && INPUT_FILE="./in/natives_global_client_compat.lua" || INPUT_FILE="skip"
[ ${{ inputs.no_input }} == false ] && INPUT_FILE="./in/$CONFIG_UPLOAD_COMPAT_FILE..lua" || INPUT_FILE="skip"
./.ci/run-compat $BUILDER_ROOT "./out/natives_global_client_compat.lua" "$INPUT_FILE" ${{ inputs.ignore_missing_input }} ${{ inputs.force }} ${{ inputs.use_history }} ${{ inputs.since_date }}
./.ci/run-compat $BUILDER_ROOT "./out/$CONFIG_UPLOAD_COMPAT_FILE.lua" "$INPUT_FILE" ${{ inputs.ignore_missing_input }} ${{ inputs.force }} ${{ inputs.use_history }} ${{ inputs.since_date }}
- name: Output -> Echo (stdout)
if: inputs.output_action == 'Echo (stdout)'
run: cat ./out/natives_global_client_compat.lua
run: |
. ./.ci/config.sh
cat "./out/$CONFIG_UPLOAD_COMPAT_FILE.lua"
- name: Output -> Artifact
if: inputs.output_action == 'Artifact'
Expand All @@ -91,6 +96,4 @@ jobs:

- name: Output -> Deploy
if: inputs.output_action == 'Deploy to remote'
env:
NATIVE_DEPLOY_URL: ${{ secrets.NATIVE_DEPLOY_URL }}
run: rsync -rqb --backup-dir=./ --suffix=.bak --include=*compat.lua --exclude=* ./out/ $NATIVE_DEPLOY_URL
run: rsync -rqb --backup-dir=./ --suffix=.bak --include=*compat.lua --exclude=* ./out/ ${{secrets.NATIVE_DEPLOY_URL}}

0 comments on commit f1f7a7d

Please sign in to comment.