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

Feat: auto update references for docs, test #150

56 changes: 56 additions & 0 deletions .github/workflows/update-ref.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Update references for commits, tags, etc

on:
workflow_dispatch:
schedule:
- cron: '0 0 1 * *' # Run on the first day of every month

jobs:
build:

runs-on: ubuntu-latest

defaults:
run:
shell: bash

env:
DBUS_SESSION_BUS_ADDRESS: unix:path=/run/user/1001/bus
SHELL: /usr/bin/bash
FILE_PATHS: |
integration-tests/src/utils/version.ts
scripts/fetch-docs.sh

strategy:
matrix:
node-version: [20]

steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Update required extension version
run: bash scripts/update-extension-version.sh

- name: Update fetch-docs script
run: bash scripts/update-fetch-docs-commits.sh

- name: Verify file changes
uses: tj-actions/verify-changed-files@v17
id: verify-changed-files
with:
files: ${{ env.FILE_PATHS }}

- name: Create pull request
if: steps.verify-changed-files.outputs.files_changed == 'true'
uses: peter-evans/create-pull-request@v5
with:
add-paths: ${{ env.FILE_PATHS }}
title: Auto update references for commits, tags, etc
commit-message: Auto update references for commits, tags, etc
token: ${{ secrets.GITHUB_TOKEN }}
5 changes: 3 additions & 2 deletions integration-tests/src/runTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
resolveCliArgsFromVSCodeExecutablePath,
runTests
} from '@vscode/test-electron'
import { pythonVersion, bashVersion } from './utils/version'

async function main (): Promise<void> {
try {
Expand All @@ -20,8 +21,8 @@ async function main (): Promise<void> {
cliPath,
[
...args,
'--install-extension', 'mads-hartmann.bash-ide-vscode@1.39.0',
'--install-extension', 'ms-python.python@2023.20.0'
'--install-extension', `mads-hartmann.bash-ide-vscode@${bashVersion}`,
'--install-extension', `ms-python.python@${pythonVersion}`
],
{
encoding: 'utf-8',
Expand Down
8 changes: 8 additions & 0 deletions integration-tests/src/utils/version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) 2023 Savoir-faire Linux. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */

// Required extension versions
export const bashVersion = '1.39.0'
export const pythonVersion = '2024.2.1'
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"postinstall": "cd server && npm install && cd ../client && npm install",
"fetch": "npm run fetch:poky && npm run fetch:docs",
"fetch:docs": "sh scripts/fetch-docs.sh",
"fetch:poky": "mkdir -p resources/poky && curl -L -o resources/poky.tar.bz2 https://downloads.yoctoproject.org/releases/yocto/yocto-4.2.3/poky-aa63b25cbe25d89ab07ca11ee72c17cab68df8de.tar.bz2 && tar -xvjf resources/poky.tar.bz2 -C resources",
"fetch:poky": "sh scripts/fetch-poky.sh",
"compile": "npm run installServer && tsc -b",
"watch": "npm run installServer && tsc -b -w",
"installServer": "cd server && npm run installServer",
Expand Down
8 changes: 5 additions & 3 deletions scripts/fetch-docs.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/bin/bash

BITBAKE_DOCS_COMMIT=595176d6be95a9c4718d3a40499d1eb576b535f5
BITBAKE_DOCS_LIST="bitbake-user-manual-metadata.rst bitbake-user-manual-ref-variables.rst"
# Tag: yocto-4.3.3
BITBAKE_DOCS_COMMIT=380a9ac97de5774378ded5e37d40b79b96761a0c
# Tag: yocto-4.3.3
YOCTO_DOCS_COMMIT=dde4b815db82196af086847f68ee27d7902b4ffa

YOCTO_DOCS_COMMIT=897d5017eae6b3af2d5d489fc4e0915d9ce21458
BITBAKE_DOCS_LIST="bitbake-user-manual-metadata.rst bitbake-user-manual-ref-variables.rst"
YOCTO_DOCS_LIST=" tasks.rst variables.rst"

set -e
Expand Down
13 changes: 13 additions & 0 deletions scripts/fetch-poky.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

set -e

mkdir -p resources/poky
cd resources/poky
git clone https://github.com/yoctoproject/poky.git .
git fetch --tags
TMP_TAG=$(git tag | grep "yocto-" | tail -n 1) # There is a tag: yocto_1.5_M5.rc8 which will take the tail, thus adding a hyphen
deribaucourt marked this conversation as resolved.
Show resolved Hide resolved
LASTEST_RELEASE=$(git show $TMP_TAG | grep commit | sed "s/^commit //")
git fetch origin
git checkout $LASTEST_RELEASE

28 changes: 28 additions & 0 deletions scripts/update-extension-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash

set -e

DEST="integration-tests/src/utils/version.ts"

# Keep the header
TOTAL_LINES=$(wc -l < $DEST)
LINES_TO_KEEP=$(($TOTAL_LINES - 2))
TMP="tmp.ts"
head -n $LINES_TO_KEEP $DEST > $TMP

git clone --depth 1 --filter=blob:none --sparse https://github.com/bash-lsp/bash-language-server
cd bash-language-server
git fetch --tags
echo "export const bashVersion = '$(git tag --sort=-v:refname | head -n 1 | sed "s/^vscode-client-//")'" >> ../$TMP
cd ..
rm -rf bash-language-server

git clone --depth 1 --filter=blob:none --sparse https://github.com/Microsoft/vscode-python
WilsonZiweiWang marked this conversation as resolved.
Show resolved Hide resolved
cd vscode-python
git fetch --tags
echo "export const pythonVersion = '$(git tag --sort=-v:refname | head -n 1 | sed "s/^v//")'" >> ../$TMP
cd ..
rm -rf vscode-python

cp $TMP $DEST
rm $TMP
32 changes: 32 additions & 0 deletions scripts/update-fetch-docs-commits.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

FILE="scripts/fetch-docs.sh"
TMP_FILE="tmp.txt"
tail -n +8 $FILE > $TMP_FILE

echo "#!/bin/bash" > $FILE
echo "" >> $FILE

git clone --depth 1 --filter=blob:none --sparse https://github.com/openembedded/bitbake.git
cd bitbake
git fetch --tags
TMP_TAG=$(git tag | tail -n 1)
LASTEST_RELEASE=$(git show $TMP_TAG | grep commit | sed "s/^commit //")
echo "# Tag: $TMP_TAG" >> ../$FILE
echo "BITBAKE_DOCS_COMMIT=$LASTEST_RELEASE" >> ../$FILE
cd ..
rm -rf bitbake

git clone --depth 1 --filter=blob:none --sparse https://git.yoctoproject.org/yocto-docs
cd yocto-docs
git fetch --tags
TMP_TAG=$(git tag | tail -n 1)
LASTEST_RELEASE=$(git show $TMP_TAG | grep commit | sed "s/^commit //")
echo "# Tag: $TMP_TAG" >> ../$FILE
echo "YOCTO_DOCS_COMMIT=$LASTEST_RELEASE" >> ../$FILE
WilsonZiweiWang marked this conversation as resolved.
Show resolved Hide resolved
echo "" >> ../$FILE
cd ..
rm -rf yocto-docs

cat $TMP_FILE >> $FILE
rm $TMP_FILE
Loading