From 72b1507fc73b2bea3dafee25ee82ada57bf9ae4b Mon Sep 17 00:00:00 2001 From: tabarra <1808295+tabarra@users.noreply.github.com> Date: Mon, 7 Oct 2024 01:49:52 -0300 Subject: [PATCH] ci: updated github actions --- .github/workflows/locale-pull-request.yml | 54 +++++++---------------- .github/workflows/publish-tagged.yml | 4 +- .github/workflows/run-tests.yml | 33 ++++++++++++++ core/extras/testEnv.ts | 4 ++ docs/dev_notes.md | 2 +- nui/package.json | 1 + package.json | 2 +- shared/package.json | 1 + 8 files changed, 60 insertions(+), 41 deletions(-) create mode 100644 .github/workflows/run-tests.yml diff --git a/.github/workflows/locale-pull-request.yml b/.github/workflows/locale-pull-request.yml index ef63c010f..5c1692c6c 100644 --- a/.github/workflows/locale-pull-request.yml +++ b/.github/workflows/locale-pull-request.yml @@ -12,53 +12,33 @@ jobs: pull-requests: write steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Use Node.js 20 - uses: actions/setup-node@v4 - with: - node-version: 20 - - - name: Install dependencies - run: npm ci - - - name: Label PR and enforce base branch + - name: Enforce base branch uses: actions/github-script@v7 with: script: | - // console.warn('This is bugged and doesn\'t work, skip this step for now!'); - // process.exit(0); - - // Add the 'translation' label - github.rest.issues.addLabels({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - labels: ['translation'] - }); - - console.log(JSON.stringify(context.payload.pull_request)); - const { repo, owner } = context.repo; - // Get the pull request - const pull_number = context.payload.pull_request.number; const pull_request = await github.rest.pulls.get({ - owner, - repo, - pull_number + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.payload.pull_request.number }); // Check if the base branch is 'main' or 'master' if (pull_request.data.base.ref === 'main' || pull_request.data.base.ref === 'master') { - // Change the base branch to 'develop' - await github.rest.pulls.update({ - owner, - repo, - pull_number, - base: 'develop' - }); + console.error('Pull request is targeting the main branch. Please target the develop branch instead.'); + process.exit(1); } + + - name: Use Node.js 22 + uses: actions/setup-node@v4 + with: + node-version: 22 + + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install dependencies + run: npm ci - name: Run locale:check id: locale-check diff --git a/.github/workflows/publish-tagged.yml b/.github/workflows/publish-tagged.yml index 80886cf75..24b1820c4 100644 --- a/.github/workflows/publish-tagged.yml +++ b/.github/workflows/publish-tagged.yml @@ -20,10 +20,10 @@ jobs: with: fetch-depth: 0 - - name: Use Node.js 20 + - name: Use Node.js 22 uses: actions/setup-node@v4 with: - node-version: 20 + node-version: 22 - name: Download all modules run: npm ci diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml new file mode 100644 index 000000000..cbb69db7b --- /dev/null +++ b/.github/workflows/run-tests.yml @@ -0,0 +1,33 @@ +name: Run Tests for Workspaces + +on: + push: + branches: + - master + pull_request: + branches: + - "**" + +jobs: + run-tests: + name: "Run Unit Testing" + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Use Node.js 22 + uses: actions/setup-node@v4 + with: + node-version: 22 + + - name: Download all modules + run: npm ci + + - name: Run Tests + env: + CI: true + run: npm run test --workspaces diff --git a/core/extras/testEnv.ts b/core/extras/testEnv.ts index a63062abe..464c47b4c 100644 --- a/core/extras/testEnv.ts +++ b/core/extras/testEnv.ts @@ -6,6 +6,10 @@ vi.stubEnv('TERM', 'xterm-256color'); vi.stubEnv('FORCE_COLOR', '3'); vi.stubEnv('TXADMIN_DEV_SRC_PATH', path.join(process.cwd(), '..')); vi.stubEnv('TXADMIN_DEV_VITE_URL', 'http://localhost:40122'); +if (process.env.CI) { + const citizenRoot = path.join(process.cwd(), 'alpine/opt/cfx-server/'); + vi.stubEnv('TXADMIN_DEV_FXSERVER_PATH', citizenRoot); +} // Stubbing globals diff --git a/docs/dev_notes.md b/docs/dev_notes.md index fa7e674e1..3abdee5b1 100644 --- a/docs/dev_notes.md +++ b/docs/dev_notes.md @@ -154,7 +154,7 @@ Legend: - [x] buffer fxserver lrstream for 5 seconds before stripping colors - [x] fix(core): a `EMFILE: too many open files` error on windows will cause the `admins.json` to reset - [ref](/core/components/AdminVault/index.js#L289) -- [!] check cicd stuff on testing repo before release +- [x] check cicd stuff on testing repo before release - [?] add `.yarn.installed` to the dist? even in dev - [?] check netid uint16 overflow - right now the `mutex#netid` is being calculated on [logger](/core/components/Logger/handlers/server.js#L148) diff --git a/nui/package.json b/nui/package.json index d7040f104..7b4860e33 100644 --- a/nui/package.json +++ b/nui/package.json @@ -5,6 +5,7 @@ "main": "index.js", "type": "module", "scripts": { + "test": "echo \"No tests for this workspace. Skipping...\"", "build": "vite build --mode production", "dev": "vite build --watch --mode development", "browser": "vite dev --port 40121 --strictPort --mode devNuiBrowser", diff --git a/package.json b/package.json index c3f8c7952..d14e24722 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "scripts": { "build": "rimraf dist tmp_core_tsc && npm run build -w nui && npm run build -w panel && npm run build -w core && npm run license:distfile", "prepare": "husky", - "test": "bash ./scripts/test_build.sh", + "test": "npm run test --workspaces", "typecheck": "npm run typecheck --workspaces", "locale:rebase": "node scripts/locale-utils.js rebase", "locale:check": "node scripts/locale-utils.js check --color", diff --git a/shared/package.json b/shared/package.json index 0b7d3e0b4..d9b367111 100644 --- a/shared/package.json +++ b/shared/package.json @@ -4,6 +4,7 @@ "description": "The shared package contains stuff used in more than one package, no build step required.", "main": "index.js", "scripts": { + "test": "echo \"No tests for this workspace. Skipping...\"", "typecheck": "tsc -p tsconfig.json --noEmit", "license:report": "npx license-report > ../.reports/license/shared.html" },