cache window bin and support dev
This commit is contained in:
@@ -8,13 +8,17 @@ jobs:
|
||||
checkin:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.ref }}-${{ github.base_ref }}-${{ github.head_ref }}-checkin
|
||||
cancel-in-progress: true
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: install
|
||||
uses: wyvox/action-setup-pnpm@v3
|
||||
with:
|
||||
node-version: 20
|
||||
pnpm-version: 8
|
||||
node-version: 23
|
||||
pnpm-version: 9
|
||||
- name: build
|
||||
run: pnpm build
|
||||
- name: test
|
||||
|
||||
@@ -5,6 +5,10 @@ on:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
concurrency:
|
||||
group: ${{ github.ref }}-${{ github.base_ref }}-${{ github.head_ref }}-${{ matrix.os }}-${{ matrix.version }}-test
|
||||
cancel-in-progress: true
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest, macOS-latest]
|
||||
@@ -14,9 +18,11 @@ jobs:
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: xmake-io/github-action-setup-xmake@master
|
||||
- uses: xmake-io/github-action-setup-xmake@test
|
||||
with:
|
||||
xmake-version: ${{ matrix.version }}
|
||||
actions-cache-folder: '.xmake-cache'
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
xmake --version
|
||||
|
||||
@@ -85,3 +85,14 @@ git tag v1
|
||||
git push origin master
|
||||
git push --tags --force
|
||||
```
|
||||
|
||||
### Development and debug
|
||||
|
||||
```bash
|
||||
git branch test
|
||||
git checkout test
|
||||
pnpm build
|
||||
pnpm release
|
||||
git-commit -a -m "..."
|
||||
git push origin test
|
||||
```
|
||||
|
||||
Vendored
+61
-1
@@ -82596,6 +82596,7 @@ async function unixInstall(version) {
|
||||
}
|
||||
fs.accessSync(path.join(fullCachePath, 'bin', 'xmake'), fs.constants.X_OK);
|
||||
toolDir = fullCachePath;
|
||||
core.info(`cache path: ${toolDir}, key: ${cacheKey}`);
|
||||
}
|
||||
catch (_c) {
|
||||
core.warning(`No cached files found at path "${fullCachePath}".`);
|
||||
@@ -82827,9 +82828,12 @@ const core = __nccwpck_require__(9093);
|
||||
const exec_1 = __nccwpck_require__(7775);
|
||||
const io = __nccwpck_require__(2826);
|
||||
const toolCache = __nccwpck_require__(5561);
|
||||
const cache = __nccwpck_require__(6878);
|
||||
const os = __nccwpck_require__(2037);
|
||||
const fs = __nccwpck_require__(7147);
|
||||
const path = __nccwpck_require__(1017);
|
||||
const semver = __nccwpck_require__(117);
|
||||
const git = __nccwpck_require__(3555);
|
||||
function getInstallerUrl(version, latest) {
|
||||
const ver = version.version;
|
||||
switch (version.type) {
|
||||
@@ -82857,12 +82861,45 @@ function getInstallerUrl(version, latest) {
|
||||
}
|
||||
}
|
||||
}
|
||||
async function installFromSource(xmakeBin, sourceDir, binDir) {
|
||||
await (0, exec_1.exec)(xmakeBin, ['-y'], { cwd: sourceDir });
|
||||
await (0, exec_1.exec)(xmakeBin, ['install', '-o', binDir, 'cli'], { cwd: sourceDir });
|
||||
}
|
||||
async function winInstall(version, latest) {
|
||||
var _a;
|
||||
if (version.type === 'local' || latest.type === 'local') {
|
||||
throw new Error('Local builds for windows is not supported');
|
||||
}
|
||||
const actionsCacheFolder = core.getInput('actions-cache-folder');
|
||||
let actionsCacheKey = core.getInput('actions-cache-key');
|
||||
if (!actionsCacheKey) {
|
||||
actionsCacheKey = '';
|
||||
}
|
||||
const ver = version.version;
|
||||
let toolDir = toolCache.find('xmake', ver);
|
||||
const sha = version.sha;
|
||||
const cacheKey = `xmake-cache-${actionsCacheKey}-${ver}-${sha}-${os.arch()}-${os.platform()}-${(_a = process.env.RUNNER_OS) !== null && _a !== void 0 ? _a : 'unknown'}`;
|
||||
let toolDir = '';
|
||||
if (actionsCacheFolder && process.env.GITHUB_WORKSPACE) {
|
||||
const fullCachePath = path.join(process.env.GITHUB_WORKSPACE, actionsCacheFolder);
|
||||
try {
|
||||
try {
|
||||
fs.accessSync(path.join(fullCachePath, 'xmake.exe'), fs.constants.X_OK);
|
||||
}
|
||||
catch (_b) {
|
||||
await cache.restoreCache([actionsCacheFolder], cacheKey);
|
||||
}
|
||||
fs.accessSync(path.join(fullCachePath, 'xmake.exe'), fs.constants.X_OK);
|
||||
toolDir = fullCachePath;
|
||||
core.info(`cache path: ${toolDir}, key: ${cacheKey}`);
|
||||
}
|
||||
catch (_c) {
|
||||
core.warning(`No cached files found at path "${fullCachePath}".`);
|
||||
await io.rmRF(fullCachePath);
|
||||
}
|
||||
}
|
||||
else {
|
||||
toolDir = toolCache.find('xmake', ver);
|
||||
}
|
||||
if (!toolDir) {
|
||||
const installer = await core.group(`download xmake ${String(version)}`, async () => {
|
||||
const url = getInstallerUrl(version, latest);
|
||||
@@ -82887,6 +82924,29 @@ async function winInstall(version, latest) {
|
||||
await io.rmRF(installer);
|
||||
return cacheDir;
|
||||
});
|
||||
await (0, exec_1.exec)(`"${toolDir}/xmake.exe" --version`);
|
||||
if (version.type === 'heads') {
|
||||
const sourceDir = await core.group(`download xmake source ${String(version)}`, () => git.create(version.repo, version.sha));
|
||||
toolDir = await core.group(`install xmake source ${String(version)}`, async () => {
|
||||
const binDir = path.join(os.tmpdir(), `xmake-${version.sha}`);
|
||||
await installFromSource(`${toolDir}/xmake.exe`, `${sourceDir}/core`, binDir);
|
||||
const cacheDir = await toolCache.cacheDir(binDir, 'xmake', ver);
|
||||
await io.rmRF(binDir);
|
||||
await git.cleanup(version.sha);
|
||||
return cacheDir;
|
||||
});
|
||||
}
|
||||
if (toolDir) {
|
||||
let cacheDir = '';
|
||||
if (actionsCacheFolder && process.env.GITHUB_WORKSPACE) {
|
||||
cacheDir = path.join(process.env.GITHUB_WORKSPACE, actionsCacheFolder);
|
||||
await io.cp(toolDir, cacheDir, {
|
||||
recursive: true,
|
||||
});
|
||||
await cache.saveCache([actionsCacheFolder], cacheKey);
|
||||
toolDir = cacheDir;
|
||||
}
|
||||
}
|
||||
}
|
||||
core.addPath(toolDir);
|
||||
}
|
||||
|
||||
Generated
+6092
File diff suppressed because it is too large
Load Diff
Generated
+2748
-2296
File diff suppressed because it is too large
Load Diff
@@ -46,6 +46,7 @@ export async function unixInstall(version: Version): Promise<void> {
|
||||
}
|
||||
fs.accessSync(path.join(fullCachePath, 'bin', 'xmake'), fs.constants.X_OK);
|
||||
toolDir = fullCachePath;
|
||||
core.info(`cache path: ${toolDir}, key: ${cacheKey}`);
|
||||
} catch {
|
||||
core.warning(`No cached files found at path "${fullCachePath}".`);
|
||||
await io.rmRF(fullCachePath);
|
||||
|
||||
+67
-1
@@ -2,9 +2,12 @@ import * as core from '@actions/core';
|
||||
import { exec } from '@actions/exec';
|
||||
import * as io from '@actions/io';
|
||||
import * as toolCache from '@actions/tool-cache';
|
||||
import * as cache from '@actions/cache';
|
||||
import * as os from 'os';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import * as semver from 'semver';
|
||||
import * as git from './git';
|
||||
import { Version, GitVersion } from './interfaces';
|
||||
|
||||
function getInstallerUrl(version: GitVersion, latest: GitVersion): string {
|
||||
@@ -35,12 +38,48 @@ function getInstallerUrl(version: GitVersion, latest: GitVersion): string {
|
||||
}
|
||||
}
|
||||
|
||||
async function installFromSource(xmakeBin: string, sourceDir: string, binDir: string): Promise<void> {
|
||||
await exec(xmakeBin, ['-y'], { cwd: sourceDir });
|
||||
await exec(xmakeBin, ['install', '-o', binDir, 'cli'], { cwd: sourceDir });
|
||||
}
|
||||
|
||||
export async function winInstall(version: Version, latest: Version): Promise<void> {
|
||||
if (version.type === 'local' || latest.type === 'local') {
|
||||
throw new Error('Local builds for windows is not supported');
|
||||
}
|
||||
|
||||
const actionsCacheFolder = core.getInput('actions-cache-folder');
|
||||
let actionsCacheKey = core.getInput('actions-cache-key');
|
||||
if (!actionsCacheKey) {
|
||||
actionsCacheKey = '';
|
||||
}
|
||||
|
||||
const ver = version.version;
|
||||
let toolDir = toolCache.find('xmake', ver);
|
||||
const sha = version.sha;
|
||||
const cacheKey = `xmake-cache-${actionsCacheKey}-${ver}-${sha}-${os.arch()}-${os.platform()}-${
|
||||
process.env.RUNNER_OS ?? 'unknown'
|
||||
}`;
|
||||
|
||||
let toolDir = '';
|
||||
if (actionsCacheFolder && process.env.GITHUB_WORKSPACE) {
|
||||
const fullCachePath = path.join(process.env.GITHUB_WORKSPACE, actionsCacheFolder);
|
||||
try {
|
||||
try {
|
||||
fs.accessSync(path.join(fullCachePath, 'xmake.exe'), fs.constants.X_OK);
|
||||
} catch {
|
||||
await cache.restoreCache([actionsCacheFolder], cacheKey);
|
||||
}
|
||||
fs.accessSync(path.join(fullCachePath, 'xmake.exe'), fs.constants.X_OK);
|
||||
toolDir = fullCachePath;
|
||||
core.info(`cache path: ${toolDir}, key: ${cacheKey}`);
|
||||
} catch {
|
||||
core.warning(`No cached files found at path "${fullCachePath}".`);
|
||||
await io.rmRF(fullCachePath);
|
||||
}
|
||||
} else {
|
||||
toolDir = toolCache.find('xmake', ver);
|
||||
}
|
||||
|
||||
if (!toolDir) {
|
||||
const installer = await core.group(`download xmake ${String(version)}`, async () => {
|
||||
const url = getInstallerUrl(version, latest);
|
||||
@@ -65,6 +104,33 @@ export async function winInstall(version: Version, latest: Version): Promise<voi
|
||||
await io.rmRF(installer);
|
||||
return cacheDir;
|
||||
});
|
||||
await exec(`"${toolDir}/xmake.exe" --version`);
|
||||
if (version.type === 'heads') {
|
||||
const sourceDir = await core.group(`download xmake source ${String(version)}`, () =>
|
||||
git.create(version.repo, version.sha),
|
||||
);
|
||||
toolDir = await core.group(`install xmake source ${String(version)}`, async () => {
|
||||
const binDir = path.join(os.tmpdir(), `xmake-${version.sha}`);
|
||||
await installFromSource(`${toolDir}/xmake.exe`, `${sourceDir}/core`, binDir);
|
||||
const cacheDir = await toolCache.cacheDir(binDir, 'xmake', ver);
|
||||
|
||||
await io.rmRF(binDir);
|
||||
await git.cleanup(version.sha);
|
||||
return cacheDir;
|
||||
});
|
||||
}
|
||||
|
||||
if (toolDir) {
|
||||
let cacheDir = '';
|
||||
if (actionsCacheFolder && process.env.GITHUB_WORKSPACE) {
|
||||
cacheDir = path.join(process.env.GITHUB_WORKSPACE, actionsCacheFolder);
|
||||
await io.cp(toolDir, cacheDir, {
|
||||
recursive: true,
|
||||
});
|
||||
await cache.saveCache([actionsCacheFolder], cacheKey);
|
||||
toolDir = cacheDir;
|
||||
}
|
||||
}
|
||||
}
|
||||
core.addPath(toolDir);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user