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

Initial auto-updater #60

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
37 changes: 37 additions & 0 deletions .github/workflows/update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Update output.json

on:
schedule:
- cron: '31 5 * * *' # Once per day, random time
workflow_dispatch:

permissions: {}

jobs:
update:
runs-on: ubuntu-latest
defaults:
run:
working-directory: './scripts/update'
steps:
- name: Checkout self
uses: actions/checkout@v3

- name: Checkout vcpkg
uses: actions/checkout@v3
with:
repository: 'microsoft/vcpkg'
path: 'vcpkg'

- uses: actions/setup-node@v3
with:
node-version: '16'

- run: npm ci

- run: npm run start $GITHUB_WORKSPACE/vcpkg $GITHUB_TOKEN

- uses: actions/upload-artifact@v3
with:
name: 'output.json'
path: './output.json'
18 changes: 12 additions & 6 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": ["<node_internals>/**"],
"program": "${file}"
"name": "Launch Updater",
"runtimeArgs": [
"--loader",
"ts-node/esm"
],
"args": [
"${workspaceFolder}/scripts/update/index.ts",
"${workspaceFolder}/vcpkg"
],
"env": {
"TS_NODE_PROJECT": "${workspaceFolder}/scripts/update/tsconfig.json"
}
}
]
}
5 changes: 0 additions & 5 deletions .vscode/settings.json

This file was deleted.

46 changes: 46 additions & 0 deletions scripts/update/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import * as path from 'path';
import fs from 'fs-extra';
import { exit } from 'process';
import { addVersions } from './tasks/add-versions.js';
import { readPackages } from './tasks/read-packages.js';
import { addStars } from './tasks/add-stars.js';
import { addStatus } from './tasks/add-status.js';
import { Manifest } from './types';
import { readTriplets } from './tasks/read-triplets.js';

if (!process.argv[2]) {
console.error('missing path to vcpkg repository');
exit(-1);
JamieMagee marked this conversation as resolved.
Show resolved Hide resolved
}

const sourcePath = process.argv[2];
const portsPath = path.join(sourcePath, 'ports');
const versionsPath = path.join(sourcePath, 'versions');
const baselinePath = path.join(sourcePath, 'scripts', 'ci.baseline.txt');
const tripletsPath = path.join(sourcePath, 'triplets');

const triplets = await readTriplets(tripletsPath);

const manifests = await readPackages(portsPath);
const manifestsWithVersions = await addVersions(versionsPath, manifests);
const manifestsWithVersionsAndStatus = await addStatus(
baselinePath,
triplets,
manifestsWithVersions,
);

let manifestsWithVersionsAndStatusAndStars: Manifest[] | undefined = undefined;
if (process.argv[3]) {
manifestsWithVersionsAndStatusAndStars = await addStars(
manifestsWithVersionsAndStatus,
process.argv[3],
);
} else {
console.warn('Missing GitHub token. Skipping fetching stars');
}

await fs.writeJson(
'output.json',
manifestsWithVersionsAndStatusAndStars ?? manifestsWithVersionsAndStatus,
{ spaces: 2 },
);
Loading