From c2277774bdab31866c0540749e4a5f1dee8bd7da Mon Sep 17 00:00:00 2001 From: Egor Zalenski Date: Sun, 27 Oct 2024 14:48:14 +0100 Subject: [PATCH 1/9] try build --- .github/actions/download-backend/action.yml | 13 + .../actions/install-all-build-libs/action.yml | 28 ++ .github/build/sum_sha256.sh | 4 + .github/deps-licenses-report.js | 250 ++++++++++++++++++ .github/e2e/e2e-results.js | 57 ++++ .github/e2e/test.app.sh | 14 + .github/workflows/aws.yml | 33 +++ .github/workflows/build.yml | 64 +++++ .github/workflows/licenses-check.yml | 32 +++ .github/workflows/pipeline-build-linux.yml | 77 ++++++ .github/workflows/pipeline-build-macos.yml | 74 ++++++ .github/workflows/pipeline-build-windows.yml | 55 ++++ .github/workflows/release-prod.yml | 33 +++ .github/workflows/release-stage.yml | 30 +++ .github/workflows/tests-e2e-linux.yml | 104 ++++++++ .github/workflows/tests-frontend.yml | 38 +++ .github/workflows/tests.yml | 37 +++ .github/workflows/weekly.yml | 9 + .gitignore | 7 + vite.config.mjs | 14 +- 20 files changed, 969 insertions(+), 4 deletions(-) create mode 100644 .github/actions/download-backend/action.yml create mode 100644 .github/actions/install-all-build-libs/action.yml create mode 100755 .github/build/sum_sha256.sh create mode 100644 .github/deps-licenses-report.js create mode 100644 .github/e2e/e2e-results.js create mode 100755 .github/e2e/test.app.sh create mode 100644 .github/workflows/aws.yml create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/licenses-check.yml create mode 100644 .github/workflows/pipeline-build-linux.yml create mode 100644 .github/workflows/pipeline-build-macos.yml create mode 100644 .github/workflows/pipeline-build-windows.yml create mode 100644 .github/workflows/release-prod.yml create mode 100644 .github/workflows/release-stage.yml create mode 100644 .github/workflows/tests-e2e-linux.yml create mode 100644 .github/workflows/tests-frontend.yml create mode 100644 .github/workflows/tests.yml create mode 100644 .github/workflows/weekly.yml diff --git a/.github/actions/download-backend/action.yml b/.github/actions/download-backend/action.yml new file mode 100644 index 00000000..40ffea99 --- /dev/null +++ b/.github/actions/download-backend/action.yml @@ -0,0 +1,13 @@ +name: Download backend + +inputs: + arch: + description: Architecture arm64 or x64 + required: false + default: 'x64' + +runs: + using: 'composite' + steps: + - name: Download backend + run: yarn download:backend ${{ inputs.arch }} diff --git a/.github/actions/install-all-build-libs/action.yml b/.github/actions/install-all-build-libs/action.yml new file mode 100644 index 00000000..7b6a0d82 --- /dev/null +++ b/.github/actions/install-all-build-libs/action.yml @@ -0,0 +1,28 @@ +name: Install all libraries action +description: Install all libraries and dependencies + +runs: + using: 'composite' + steps: + # OS libraries + - name: Setup Node + uses: actions/setup-node@v4.0.4 + with: + node-version: '20.15' + # disable cache for windows + # https://github.com/actions/setup-node/issues/975 + cache: ${{ runner.os != 'Windows' && 'yarn' || '' }} + cache-dependency-path: ${{ runner.os != 'Windows' && '**/yarn.lock' || '' }} + + # - name: Setup Python + # uses: actions/setup-python@v5 + # with: + # python-version: '3.11' + + - name: Install TypeScript + run: yarn global add typescript + + - name: Install dependencies for root package.js + run: yarn install --frozen-lockfile + + # run: yarn install diff --git a/.github/build/sum_sha256.sh b/.github/build/sum_sha256.sh new file mode 100755 index 00000000..4af88b1e --- /dev/null +++ b/.github/build/sum_sha256.sh @@ -0,0 +1,4 @@ +#!/bin/bash +set -e + +find ./release -type f -name '*.tar.gz' -execdir sh -c 'sha256sum "$1" > "$1.sha256"' _ {} \; diff --git a/.github/deps-licenses-report.js b/.github/deps-licenses-report.js new file mode 100644 index 00000000..844e2ce0 --- /dev/null +++ b/.github/deps-licenses-report.js @@ -0,0 +1,250 @@ +const fs = require('fs'); +const { join } = require('path'); +const { last, set } = require('lodash'); +const { google } = require('googleapis'); +const { exec } = require('child_process'); +const csvParser = require('csv-parser'); +const { stringify } = require('csv-stringify'); + +const licenseFolderName = 'licenses'; +const spreadsheetId = process.env.SPREADSHEET_ID; +const summaryFilePath = `./${licenseFolderName}/summary.csv`; +const allData = []; +let csvFiles = []; + +// Main function +async function main() { + const folderPath = './'; + const packageJsons = findPackageJsonFiles(folderPath); // Find all package.json files in the given folder + + console.log('All package.jsons was found:', packageJsons); + + // Create the folder if it doesn't exist + if (!fs.existsSync(licenseFolderName)) { + fs.mkdirSync(licenseFolderName); + } + + try { + await Promise.all(packageJsons.map(runLicenseCheck)); + console.log('All csv files was generated'); + await generateSummary() + await sendLicensesToGoogleSheet() + } catch (error) { + console.error('An error occurred:', error); + process.exit(1); + } +} + +main(); + +// Function to find all package.json files in a given folder +function findPackageJsonFiles(folderPath) { + const packageJsonPaths = []; + const packageJsonName = 'package.json'; + const excludeFolders = ['dist', 'node_modules', 'test-extensions']; + + // Recursive function to search for package.json files + function searchForPackageJson(currentPath) { + const files = fs.readdirSync(currentPath); + + for (const file of files) { + const filePath = join(currentPath, file); + const stats = fs.statSync(filePath); + + if (stats.isDirectory() && !excludeFolders.includes(file)) { + searchForPackageJson(filePath); + } else if (file === packageJsonName) { + packageJsonPaths.push(`./${filePath.slice(0, -packageJsonName.length - 1)}`); + } + } + } + + searchForPackageJson(folderPath); + return packageJsonPaths; +} + +// Function to run license check for a given package.json file +async function runLicenseCheck(path) { + const name = last(path.split('/')) || 'vscode'; + + const COMMANDS = [ + `license-checker --start ${path} --csv --out ./${licenseFolderName}/${name}_prod.csv --production`, + `license-checker --start ${path} --csv --out ./${licenseFolderName}/${name}_dev.csv --development`, + ] + + return await Promise.all(COMMANDS.map((command) => + new Promise((resolve, reject) => { + exec(command, (error, stdout, stderr) => { + if (error) { + console.error(`Failed command: ${command}, error:`, stderr); + reject(error); + } + resolve(); + }); + }) + )); +} + +async function sendLicensesToGoogleSheet() { + try { + const serviceAccountKey = JSON.parse(fs.readFileSync('./gasKey.json', 'utf-8')); + + // Set up JWT client + const jwtClient = new google.auth.JWT( + serviceAccountKey.client_email, + null, + serviceAccountKey.private_key, + ['https://www.googleapis.com/auth/spreadsheets'] + ); + + const sheets = google.sheets('v4'); + + // Read all .csv files in the 'licenses' folder + csvFiles.forEach((csvFile) => { + // Extract sheet name from file name + const sheetName = csvFile.replace('.csv', '').replaceAll('_', ' '); + + const data = []; + fs.createReadStream(`./${licenseFolderName}/${csvFile}`) + .pipe(csvParser({ headers: false })) + .on('data', (row) => { + data.push(Object.values(row)); + }) + .on('end', async () => { + const resource = { values: data }; + + try { + const response = await sheets.spreadsheets.get({ + auth: jwtClient, + spreadsheetId, + }); + + const sheet = response.data.sheets.find((sheet) => sheet.properties.title === sheetName); + if (sheet) { + // Clear contents of the sheet starting from cell A2 + await sheets.spreadsheets.values.clear({ + auth: jwtClient, + spreadsheetId, + range: `${sheetName}!A1:Z`, // Assuming Z is the last column + }); + } else { + // Create the sheet if it doesn't exist + await sheets.spreadsheets.batchUpdate({ + auth: jwtClient, + spreadsheetId, + resource: set({}, 'requests[0].addSheet.properties.title', sheetName), + }); + } + } catch (error) { + console.error(`Error checking/creating sheet for ${sheetName}:`, error); + } + + try { + await sheets.spreadsheets.values.batchUpdate({ + auth: jwtClient, + spreadsheetId, + resource: { + valueInputOption: 'RAW', + data: [ + { + range: `${sheetName}!A1`, // Use the sheet name as the range and start from A2 + majorDimension: 'ROWS', + values: data, + }, + ], + }, + }); + + console.log(`CSV data has been inserted into ${sheetName} sheet.`); + } catch (err) { + console.error(`Error inserting data for ${sheetName}:`, err); + } + }); + }); + } catch (error) { + console.error('Error loading service account key:', error); + } +} + +// Function to read and process each CSV file +const processCSVFile = (file) => { + return new Promise((resolve, reject) => { + const parser = csvParser({ columns: true, trim: true }); + const input = fs.createReadStream(`./${licenseFolderName}/${file}`); + + parser.on('data', (record) => { + allData.push(record); + }); + + parser.on('end', () => { + resolve(); + }); + + parser.on('error', (err) => { + reject(err); + }); + + input.pipe(parser); + }); +}; + +// Process and aggregate license data +const processLicenseData = () => { + const licenseCountMap = {}; + for (const record of allData) { + const license = record.license; + licenseCountMap[license] = (licenseCountMap[license] || 0) + 1; + } + return licenseCountMap; +}; + +// Create summary CSV data +const createSummaryData = (licenseCountMap) => { + const summaryData = [['License', 'Count']]; + for (const license in licenseCountMap) { + summaryData.push([license, licenseCountMap[license]]); + } + return summaryData; +}; + +// Write summary CSV file +const writeSummaryCSV = async (summaryData) => { + try { + const summaryCsvString = await stringifyPromise(summaryData); + fs.writeFileSync(summaryFilePath, summaryCsvString); + csvFiles.push(last(summaryFilePath.split('/'))); + console.log(`Summary CSV saved as ${summaryFilePath}`); + } catch (err) { + console.error(`Error: ${err}`); + } +}; + +// Stringify as a promise +const stringifyPromise = (data) => { + return new Promise((resolve, reject) => { + stringify(data, (err, csvString) => { + if (err) { + reject(err); + } else { + resolve(csvString); + } + }); + }); +}; + +async function generateSummary() { + csvFiles = fs.readdirSync(licenseFolderName).filter(file => file.endsWith('.csv')).sort(); + + for (const file of csvFiles) { + try { + await processCSVFile(file); + } catch (err) { + console.error(`Error processing ${file}: ${err}`); + } + } + + const licenseCountMap = processLicenseData(); + const summaryData = createSummaryData(licenseCountMap); + + await writeSummaryCSV(summaryData); +} diff --git a/.github/e2e/e2e-results.js b/.github/e2e/e2e-results.js new file mode 100644 index 00000000..5f60e3d9 --- /dev/null +++ b/.github/e2e/e2e-results.js @@ -0,0 +1,57 @@ +const fs = require('fs'); + +let parallelNodeInfo = ''; +const totalNodes = parseInt(process.env.CIRCLE_NODE_TOTAL, 10); +if (totalNodes > 1) { + parallelNodeInfo = ` (node: ${parseInt(process.env.CIRCLE_NODE_INDEX, 10) + 1}/${totalNodes})` +} + +const file = fs.readdirSync('tests/e2e/mochawesome-report').find(file => file.endsWith('-setup-report.json')) +const appBuildType = process.env.APP_BUILD_TYPE || 'VSCode (Linux)' +const results = { + message: { + text: `*E2ETest - ${appBuildType}${parallelNodeInfo}* (Branch: *${process.env.CIRCLE_BRANCH}*)` + + `\n`, + attachments: [], + }, +}; + +const result = JSON.parse(fs.readFileSync(file, 'utf-8')) +const testRunResult = { + color: '#36a64f', + title: `Started at: *${result.stats.start}`, + text: `Executed ${result.stats.tests} in ${(new Date(result.stats.end) - new Date(result.stats.start)) / 1000}s`, + fields: [ + { + title: 'Passed', + value: result.stats.passes, + short: true, + }, + { + title: 'Skipped', + value: result.stats.skipped, + short: true, + }, + ], +}; +const failed = result.stats.failures; +if (failed) { + results.passed = false; + testRunResult.color = '#cc0000'; + testRunResult.fields.push({ + title: 'Failed', + value: failed, + short: true, + }); +} + +results.message.attachments.push(testRunResult); + +if (results.passed === false) { + results.message.text = ' ' + results.message.text; +} + +fs.writeFileSync('e2e.report.json', JSON.stringify({ + channel: process.env.SLACK_TEST_REPORT_CHANNEL, + ...results.message, +})); diff --git a/.github/e2e/test.app.sh b/.github/e2e/test.app.sh new file mode 100755 index 00000000..44e32fbc --- /dev/null +++ b/.github/e2e/test.app.sh @@ -0,0 +1,14 @@ +#!/bin/bash +set -e + +# Create folder before tests run to prevent permissions issues +mkdir -p tests/e2e/remote + +# Run RTE (Redis Test Environment) +docker compose -f tests/e2e/rte.docker-compose.yml build +docker compose -f tests/e2e/rte.docker-compose.yml up --force-recreate -d -V +./tests/e2e/wait-for-redis.sh localhost 12000 + +# Run tests +RI_SOCKETS_CORS=true \ +yarn --cwd tests/e2e dotenv -e .ci.env yarn --cwd tests/e2e test:ci diff --git a/.github/workflows/aws.yml b/.github/workflows/aws.yml new file mode 100644 index 00000000..d353c6c5 --- /dev/null +++ b/.github/workflows/aws.yml @@ -0,0 +1,33 @@ +name: AWS + +on: + workflow_call: + +env: + AWS_BUCKET_NAME: ${{ secrets.AWS_BUCKET_NAME }} + AWS_DISTRIBUTION_ID: ${{ secrets.AWS_DISTRIBUTION_ID }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }} + +jobs: + release-private: + name: Release s3 private + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Download All Artifacts + uses: actions/download-artifact@v4 + with: + path: ./release + + - run: ls -R ./release + + - name: Publish private + run: | + chmod +x .github/build/sum_sha256.sh + .github/build/sum_sha256.sh + applicationVersion=$(jq -r '.version' package.json) + + aws s3 cp release/ s3://${AWS_BUCKET_NAME}/private/vscode/${applicationVersion} --recursive diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..85f851ba --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,64 @@ +name: Build + +on: + push: + branches: + - 'feature/**' + + # Manual trigger build + workflow_dispatch: + inputs: + target: + description: Build target + required: false + default: 'all' + type: choice + options: + - all + - macos:x64 + - macos:arm64 + - linux:x64 + - windows:x64 + + environment: + description: Environment to run build + type: environment + default: 'staging' + required: false + + # Called for Release workflows + workflow_call: + inputs: + environment: + description: Environment to run build + type: string + default: 'staging' + required: false + target: + description: Build target + type: string + default: 'all' + required: false + +jobs: + build-linux: + if: startsWith(inputs.target, 'linux') || endsWith(inputs.target, 'all') + uses: ./.github/workflows/pipeline-build-linux.yml + secrets: inherit + with: + environment: ${{ inputs.environment }} + + build-macos: + if: startsWith(inputs.target, 'macos') || endsWith(inputs.target, 'all') + uses: ./.github/workflows/pipeline-build-macos.yml + secrets: inherit + with: + environment: ${{ inputs.environment }} + target: ${{ inputs.target }} + + build-windows: + if: startsWith(inputs.target, 'windows') || endsWith(inputs.target, 'all') + uses: ./.github/workflows/pipeline-build-windows.yml + secrets: inherit + with: + environment: ${{ inputs.environment }} diff --git a/.github/workflows/licenses-check.yml b/.github/workflows/licenses-check.yml new file mode 100644 index 00000000..6f14d21f --- /dev/null +++ b/.github/workflows/licenses-check.yml @@ -0,0 +1,32 @@ +name: Licenses check pipeline +on: + workflow_call: + workflow_dispatch: + +jobs: + licenses-check: + name: Licenses check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install all libs and dependencies + uses: ./.github/actions/install-all-build-libs + + - name: Install e2e dependencies + run: yarn --cwd tests/e2e install + + - name: Generate licenses csv files and send csv data to google sheet + env: + GOOGLE_ACCOUNT_SERVICE_KEY_BASE64: ${{ secrets.GOOGLE_ACCOUNT_SERVICE_KEY_BASE64 }} + GOOGLE_SPREADSHEET_DEPENDENCIES_ID: ${{ secrets.GOOGLE_SPREADSHEET_DEPENDENCIES_ID }} + run: | + npm i -g license-checker + echo "$GOOGLE_ACCOUNT_SERVICE_KEY_BASE64" | base64 -id > gasKey.json + SPREADSHEET_ID=$GOOGLE_SPREADSHEET_DEPENDENCIES_ID node .github/deps-licenses-report.js + + - uses: actions/upload-artifact@v4 + with: + name: licenses + path: licenses + if-no-files-found: error diff --git a/.github/workflows/pipeline-build-linux.yml b/.github/workflows/pipeline-build-linux.yml new file mode 100644 index 00000000..d760c0a9 --- /dev/null +++ b/.github/workflows/pipeline-build-linux.yml @@ -0,0 +1,77 @@ +name: Build linux pipeline + +on: + workflow_call: + inputs: + environment: + description: Environment for build + required: false + default: 'staging' + type: string + +jobs: + build: + name: Build linux + runs-on: ubuntu-24.04 + environment: ${{ inputs.environment }} + + steps: + # SSH + # - name: Setup upterm session + # uses: mxschmitt/action-tmate@v3 #1 better + + - uses: actions/checkout@v4 + + # - name: Install all libs and dependencies + # uses: ./.github/actions/install-all-build-libs + - name: Setup Node + uses: actions/setup-node@v4.0.4 + with: + node-version: '20.15' + # disable cache for windows + # https://github.com/actions/setup-node/issues/975 + cache: 'yarn' + + # - name: Setup Python + # uses: actions/setup-python@v5 + # with: + # python-version: '3.11' + + - name: Install dependencies for root package.js + run: yarn install --frozen-lockfile + + + # - run: rm -rf tsconfig.json + + - name: Download backend + uses: ./.github/actions/download-backend + + # - run: ls -la ./scripts + # - run: yarn download:backend + # - run: yarn download:backend ${{ inputs.arch }} + + - name: Set RI_SEGMENT_WRITE_KEY to .env file + run: echo "RI_SEGMENT_WRITE_KEY='$RI_SEGMENT_WRITE_KEY'" >> $envFile + + - name: Build linux package (production) + if: inputs.environment == 'production' + run: | + yarn package:prod --target linux-x64 --out ${packagePath} + + - name: Build linux package (staging) + if: inputs.environment == 'staging' + run: | + sed -i "s/^RI_APP_FOLDER_NAME=.*/RI_APP_FOLDER_NAME='.redis-for-vscode-stage'/" $envFile + yarn package:stage --target linux-x64 --out ${packagePath} + + - uses: actions/upload-artifact@v4 + name: Upload extension artifact + with: + name: linux-build + path: | + release/redis-for-*.vsix + + env: + envFile: '.env' + packagePath: './release/redis-for-vscode-extension-linux-x64.vsix' + RI_SEGMENT_WRITE_KEY: ${{ secrets.RI_SEGMENT_WRITE_KEY }} diff --git a/.github/workflows/pipeline-build-macos.yml b/.github/workflows/pipeline-build-macos.yml new file mode 100644 index 00000000..ec34afff --- /dev/null +++ b/.github/workflows/pipeline-build-macos.yml @@ -0,0 +1,74 @@ +name: Build macos pipeline + +on: + workflow_call: + inputs: + environment: + description: Environment for build + required: false + default: 'staging' + type: string + + target: + description: Build target + required: false + default: 'all' + type: string + +jobs: + build: + name: Build macos + runs-on: macos-14 + environment: ${{ inputs.environment }} + + steps: + # SSH + # - name: Setup upterm session + # uses: mxschmitt/action-tmate@v3 #1 better + + - uses: actions/checkout@v4 + + - name: Install all libs and dependencies + uses: ./.github/actions/install-all-build-libs + + - name: Set RI_SEGMENT_WRITE_KEY to .env file + run: echo "RI_SEGMENT_WRITE_KEY='$RI_SEGMENT_WRITE_KEY'" >> $envFile + + - name: Download backend x64 + uses: ./.github/actions/download-backend + with: + arch: x64 + + - name: Build macos package (staging) + if: inputs.environment == 'staging' + run: | + sed -i '' "s/^RI_APP_FOLDER_NAME=.*/RI_APP_FOLDER_NAME='.redis-for-vscode-stage'/" $envFile + + yarn package:stage --target darwin-${{ inputs.target }} --out ${packagePath}-${{ inputs.target }}.vsix + + - name: Build macos x64 package (production) + if: inputs.environment == 'production' + run: | + yarn package:prod --target darwin-x64 --out ${packagePath}-x64.vsix + + - name: Download backend arm64 + uses: ./.github/actions/download-backend + with: + arch: arm64 + + - name: Build macos arm64 package (production) + if: inputs.environment == 'production' + run: | + yarn package:prod --target darwin-arm64 --out ${packagePath}-arm64.vsix + + - uses: actions/upload-artifact@v4 + name: Upload extension artifact + with: + name: macos-builds + path: | + release/redis-for-*.vsix + + env: + envFile: '.env' + packagePath: './release/redis-for-vscode-extension-mac' + RI_SEGMENT_WRITE_KEY: ${{ secrets.RI_SEGMENT_WRITE_KEY }} diff --git a/.github/workflows/pipeline-build-windows.yml b/.github/workflows/pipeline-build-windows.yml new file mode 100644 index 00000000..64993a46 --- /dev/null +++ b/.github/workflows/pipeline-build-windows.yml @@ -0,0 +1,55 @@ +name: Build windows pipeline + +on: + workflow_call: + inputs: + environment: + description: Environment for build + required: false + default: 'staging' + type: string + +jobs: + build: + name: Build windows + runs-on: windows-2022 + environment: ${{ inputs.environment }} + + steps: + # SSH debugging + # - name: Setup upterm session + # uses: mxschmitt/action-tmate@v3 #1 better + + - uses: actions/checkout@v4 + + - name: Install all libs and dependencies + uses: ./.github/actions/install-all-build-libs + + - name: Download backend + uses: ./.github/actions/download-backend + + - name: Set RI_SEGMENT_WRITE_KEY to .env file + run: echo "RI_SEGMENT_WRITE_KEY='$RI_SEGMENT_WRITE_KEY'" >> $envFile + + - name: Build windows package (production) + if: inputs.environment == 'production' + run: | + yarn package:prod --target win32-x64 --out ${packagePath} + + - name: Build windows package (staging) + if: inputs.environment == 'staging' + run: | + sed -i "s/^RI_APP_FOLDER_NAME=.*/RI_APP_FOLDER_NAME='.redis-for-vscode-stage'/" $envFile + yarn package:stage --target win32-x64 --out ${packagePath} + + - uses: actions/upload-artifact@v4 + name: Upload extension artifact + with: + name: windows-build + path: | + release/redis-for-*.vsix + + env: + envFile: '.env' + packagePath: './release/redis-for-vscode-extension-win-x64.vsix' + RI_SEGMENT_WRITE_KEY: ${{ secrets.RI_SEGMENT_WRITE_KEY }} diff --git a/.github/workflows/release-prod.yml b/.github/workflows/release-prod.yml new file mode 100644 index 00000000..ab8c08f7 --- /dev/null +++ b/.github/workflows/release-prod.yml @@ -0,0 +1,33 @@ +name: Release (prod) + +on: + push: + branches: + - 'latest' + +jobs: + tests-prod: + name: Run all tests + uses: ./.github/workflows/tests.yml + secrets: inherit + + builds-prod: + name: Create all builds for release + uses: ./.github/workflows/build.yml + needs: tests-prod + secrets: inherit + with: + environment: 'production' + target: 'all' + + e2e-linux-tests: + name: E2E Docker tests + needs: builds-prod + uses: ./.github/workflows/tests-e2e-linux.yml + secrets: inherit + + aws-prod: + name: Realse to AWS S3 + uses: ./.github/workflows/aws.yml + needs: builds-prod + secrets: inherit diff --git a/.github/workflows/release-stage.yml b/.github/workflows/release-stage.yml new file mode 100644 index 00000000..28eaf1bd --- /dev/null +++ b/.github/workflows/release-stage.yml @@ -0,0 +1,30 @@ +name: Release (stage) + +on: + push: + branches: + - 'release/**' + +jobs: + tests: + name: Release stage tests + uses: ./.github/workflows/tests.yml + secrets: inherit + + builds: + name: Release stage builds + uses: ./.github/workflows/build.yml + needs: tests + secrets: inherit + with: + environment: 'staging' + target: 'all' + + e2e-linux-tests: + needs: builds + uses: ./.github/workflows/tests-e2e-linux.yml + secrets: inherit + + + + diff --git a/.github/workflows/tests-e2e-linux.yml b/.github/workflows/tests-e2e-linux.yml new file mode 100644 index 00000000..cf6a2294 --- /dev/null +++ b/.github/workflows/tests-e2e-linux.yml @@ -0,0 +1,104 @@ +name: Tests E2E Linux +on: + workflow_call: + inputs: + report: + description: Send report to Slack + required: false + default: false + type: boolean + +env: + SLACK_TEST_REPORT_KEY: ${{ secrets.SLACK_TEST_REPORT_KEY }} + +jobs: + e2e-linux-tests: + runs-on: ubuntu-latest + name: E2E tests + container: + image: docker:latest + options: --privileged + volumes: + - /usr/src/app/results:/usr/src/app/results + - /usr/src/app/report:/usr/src/app/report + strategy: + fail-fast: false + matrix: + # Number of threads to run tests + # parallel: [0, 1, 2, 3] + parallel: [0] + + steps: + - uses: actions/checkout@v4 + + # - name: Setup repository + # run: git config --global --add safe.directory /__w/RedisInsight/Redis-for-VS-Code + + - name: Start Xvfb + run: | + apt-get install -y xvfb net-tools + Xvfb :99 -screen 0 1920x1080x24 & + + - name: Download linux artifact + uses: actions/download-artifact@v4 + with: + name: linux-build + path: ./release + + - name: Setup e2e tests + working-directory: ./tests/e2e + run: | + yarn install + yarn compile + ls -R dist/tests/ + + - name: Generate short list of the test files + working-directory: ./tests/e2e + run: | + testFiles=$(find tests -type f -name '*.e2e.js' | sort | awk "NR % 4 == ${{ matrix.parallel }}") + echo $testFiles + + # Multi-Line value + echo "TEST_FILES<> $GITHUB_ENV + echo "$testFiles" >> $GITHUB_ENV + echo "EOF" >> $GITHUB_ENV + + - name: Run tests + run: | + .github/e2e/test.app.sh + + - name: Upload Test Report + uses: actions/upload-artifact@v4 + if: always() + with: + name: report-linux-node-${{ matrix.parallel }} + path: /usr/src/app/report + + - name: Send report to Slack + if: inputs.report && always() + run: | + APP_BUILD_TYPE="VSCode (Linux)" node ./.github/e2e/e2e-results.js + # curl -H "Content-type: application/json" --data @e2e.report.json -H "Authorization: Bearer $SLACK_TEST_REPORT_KEY" -X POST https://slack.com/api/chat.postMessage + + - name: Generate test results for ${{ matrix.parallel }}th node + uses: dorny/test-reporter@v1 + if: always() + with: + name: 'Test results: E2E (linux) ${{ matrix.parallel }}th node' + path: /usr/src/app/results/results.xml + reporter: java-junit + list-tests: 'failed' + list-suites: 'failed' + fail-on-error: 'false' + + merge-artifacts: + runs-on: ubuntu-latest + needs: e2e-linux-tests + steps: + - name: Merge report artifacts + id: merge-artifacts + uses: actions/upload-artifact/merge@v4 + with: + name: report-e2e-linux + pattern: report-linux-node-* + delete-merged: true diff --git a/.github/workflows/tests-frontend.yml b/.github/workflows/tests-frontend.yml new file mode 100644 index 00000000..cca638a8 --- /dev/null +++ b/.github/workflows/tests-frontend.yml @@ -0,0 +1,38 @@ +name: Tests UI +on: + workflow_call: + +env: + SLACK_AUDIT_REPORT_KEY: ${{ secrets.SLACK_AUDIT_REPORT_KEY }} + +jobs: + unit-tests: + runs-on: ubuntu-latest + name: Frontend tests + steps: + - uses: actions/checkout@v4 + + - name: Install all libs and dependencies + uses: ./.github/actions/install-all-build-libs + + - name: Unit tests UI + run: yarn test:cov --ci --silent + + - name: Publish Test Results + uses: EnricoMi/publish-unit-test-result-action@v2 + if: always() + with: + check_name: 'FE Unit tests summary' + comment_mode: 'failures' + files: reports/junit.xml + + - name: Generate test results + uses: dorny/test-reporter@v1 + if: always() + with: + name: 'Test results: FE unit tests' + path: reports/junit.xml + reporter: jest-junit + list-tests: 'failed' + list-suites: 'failed' + fail-on-error: 'false' diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 00000000..3e38ba71 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,37 @@ +name: Tests + +on: + push: + branches: + - 'feature/**' + - 'e2e/**' + + workflow_dispatch: + workflow_call: + +jobs: + frontend-tests: + if: startsWith(github.ref_name, 'feature/') + uses: ./.github/workflows/tests-frontend.yml + secrets: inherit + + # E2E Approve + e2e-approve: + runs-on: ubuntu-latest + timeout-minutes: 60 + if: startsWith(github.ref_name, 'e2e/') + environment: ${{ startsWith(github.ref_name, 'e2e/') && 'e2e-approve' || 'staging' }} + name: Approve E2E tests + steps: + - uses: actions/checkout@v4 + + # E2E Docker + build-linux: + uses: ./.github/workflows/pipeline-build-linux.yml + needs: e2e-approve + secrets: inherit + + e2e-linux-tests: + needs: build-linux + uses: ./.github/workflows/tests-e2e-linux.yml + secrets: inherit diff --git a/.github/workflows/weekly.yml b/.github/workflows/weekly.yml new file mode 100644 index 00000000..c8c6f28f --- /dev/null +++ b/.github/workflows/weekly.yml @@ -0,0 +1,9 @@ +name: Weekly jobs +on: + schedule: + - cron: 0 0 * * 1 + +jobs: + licenses-check: + uses: ./.github/workflows/licenses-check.yml + secrets: inherit diff --git a/.gitignore b/.gitignore index 7b829b1b..f82dd99e 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ lerna-debug.log* coverage /.nyc_output **/coverage +reports # IDEs and editors /.idea @@ -59,3 +60,9 @@ scripts/*.js # security *.local + +#CI +.actrc +my.secrets +my.inputs +event.json diff --git a/vite.config.mjs b/vite.config.mjs index 89a4b6ce..546f7015 100644 --- a/vite.config.mjs +++ b/vite.config.mjs @@ -49,9 +49,7 @@ export default defineConfig({ server: { port: 8080, fs: { - allow: [ - './', - ], + allow: ['./'], }, }, envPrefix: 'RI_', @@ -89,7 +87,6 @@ export default defineConfig({ 'src/webviews/src/**/index.ts', 'src/webviews/src/**/*.d.ts', 'src/webviews/src/**/interface.ts', - 'src/webviews/src/**/*.stories.*', ], thresholds: { statements: 80, @@ -103,6 +100,15 @@ export default defineConfig({ inline: ['rawproto', 'react-monaco-editor'], }, }, + reporters: [ + 'default', + [ + 'junit', + { + outputFile: './reports/junit.xml', + }, + ], + ], }, }) From 84a9cc3d9c5f966176aea2a52d131dc843e6b2f2 Mon Sep 17 00:00:00 2001 From: Egor Zalenski Date: Sun, 27 Oct 2024 14:52:02 +0100 Subject: [PATCH 2/9] try build --- .github/workflows/build.yml | 4 ---- .github/workflows/tests.yml | 27 +++++++++++++++------------ 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 85f851ba..6dad42b2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,10 +1,6 @@ name: Build on: - push: - branches: - - 'feature/**' - # Manual trigger build workflow_dispatch: inputs: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3e38ba71..1da788de 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -16,22 +16,25 @@ jobs: secrets: inherit # E2E Approve - e2e-approve: - runs-on: ubuntu-latest - timeout-minutes: 60 - if: startsWith(github.ref_name, 'e2e/') - environment: ${{ startsWith(github.ref_name, 'e2e/') && 'e2e-approve' || 'staging' }} - name: Approve E2E tests - steps: - - uses: actions/checkout@v4 + # e2e-approve: + # runs-on: ubuntu-latest + # timeout-minutes: 60 + # if: startsWith(github.ref_name, 'e2e/') + # environment: ${{ startsWith(github.ref_name, 'e2e/') && 'e2e-approve' || 'staging' }} + # name: Approve E2E tests + # steps: + # - uses: actions/checkout@v4 # E2E Docker - build-linux: - uses: ./.github/workflows/pipeline-build-linux.yml - needs: e2e-approve + build: + uses: ./.github/workflows/build.yml secrets: inherit + # build-linux: + # uses: ./.github/workflows/pipeline-build-linux.yml + # needs: e2e-approve + # secrets: inherit e2e-linux-tests: - needs: build-linux + needs: build uses: ./.github/workflows/tests-e2e-linux.yml secrets: inherit From 53c2c2739283f6e776c043610a36e996d429f2fb Mon Sep 17 00:00:00 2001 From: Egor Zalenski Date: Sun, 27 Oct 2024 14:53:19 +0100 Subject: [PATCH 3/9] try build --- .github/actions/install-all-build-libs/action.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/actions/install-all-build-libs/action.yml b/.github/actions/install-all-build-libs/action.yml index 7b6a0d82..434d0800 100644 --- a/.github/actions/install-all-build-libs/action.yml +++ b/.github/actions/install-all-build-libs/action.yml @@ -19,10 +19,12 @@ runs: # with: # python-version: '3.11' - - name: Install TypeScript - run: yarn global add typescript + # - name: Install TypeScript + # shell: bash + # run: yarn global add typescript - name: Install dependencies for root package.js + shell: bash run: yarn install --frozen-lockfile # run: yarn install From be1cbcde2eeb82e95daedd3a1535fd7bcf9c2ef7 Mon Sep 17 00:00:00 2001 From: Egor Zalenski Date: Sun, 27 Oct 2024 14:54:54 +0100 Subject: [PATCH 4/9] try build --- .github/actions/download-backend/action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/actions/download-backend/action.yml b/.github/actions/download-backend/action.yml index 40ffea99..d70b30ff 100644 --- a/.github/actions/download-backend/action.yml +++ b/.github/actions/download-backend/action.yml @@ -10,4 +10,5 @@ runs: using: 'composite' steps: - name: Download backend + shell: bash run: yarn download:backend ${{ inputs.arch }} From c9216ca747209bb10833036285ed42e52c94107b Mon Sep 17 00:00:00 2001 From: Egor Zalenski Date: Tue, 29 Oct 2024 11:11:17 +0100 Subject: [PATCH 5/9] test build --- .../actions/install-all-build-libs/action.yml | 17 +---------------- .github/e2e/e2e-results.js | 8 ++++---- 2 files changed, 5 insertions(+), 20 deletions(-) diff --git a/.github/actions/install-all-build-libs/action.yml b/.github/actions/install-all-build-libs/action.yml index 434d0800..fb8ab13a 100644 --- a/.github/actions/install-all-build-libs/action.yml +++ b/.github/actions/install-all-build-libs/action.yml @@ -9,22 +9,7 @@ runs: uses: actions/setup-node@v4.0.4 with: node-version: '20.15' - # disable cache for windows - # https://github.com/actions/setup-node/issues/975 - cache: ${{ runner.os != 'Windows' && 'yarn' || '' }} - cache-dependency-path: ${{ runner.os != 'Windows' && '**/yarn.lock' || '' }} - - # - name: Setup Python - # uses: actions/setup-python@v5 - # with: - # python-version: '3.11' - - # - name: Install TypeScript - # shell: bash - # run: yarn global add typescript - name: Install dependencies for root package.js shell: bash - run: yarn install --frozen-lockfile - - # run: yarn install + run: yarn install --frozen-lockfile --network-timeout 1000000 diff --git a/.github/e2e/e2e-results.js b/.github/e2e/e2e-results.js index 5f60e3d9..6a4d5118 100644 --- a/.github/e2e/e2e-results.js +++ b/.github/e2e/e2e-results.js @@ -1,17 +1,17 @@ const fs = require('fs'); let parallelNodeInfo = ''; -const totalNodes = parseInt(process.env.CIRCLE_NODE_TOTAL, 10); +const totalNodes = 4; if (totalNodes > 1) { - parallelNodeInfo = ` (node: ${parseInt(process.env.CIRCLE_NODE_INDEX, 10) + 1}/${totalNodes})` + parallelNodeInfo = ` (node: ${parseInt(process.env.NODE_INDEX, 10) + 1}/${totalNodes})` } const file = fs.readdirSync('tests/e2e/mochawesome-report').find(file => file.endsWith('-setup-report.json')) const appBuildType = process.env.APP_BUILD_TYPE || 'VSCode (Linux)' const results = { message: { - text: `*E2ETest - ${appBuildType}${parallelNodeInfo}* (Branch: *${process.env.CIRCLE_BRANCH}*)` + - `\n`, + text: `*E2ETest - ${appBuildType}${parallelNodeInfo}* (Branch: *${process.env.GITHUB_REF_NAME}*)` + + `\n`, attachments: [], }, }; From 82a27f36de0fa51cfddee46cab7a693e92e1b5ec Mon Sep 17 00:00:00 2001 From: Egor Zalenski Date: Tue, 29 Oct 2024 11:13:56 +0100 Subject: [PATCH 6/9] test build --- .github/workflows/pipeline-build-windows.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pipeline-build-windows.yml b/.github/workflows/pipeline-build-windows.yml index 64993a46..5d33f051 100644 --- a/.github/workflows/pipeline-build-windows.yml +++ b/.github/workflows/pipeline-build-windows.yml @@ -34,13 +34,13 @@ jobs: - name: Build windows package (production) if: inputs.environment == 'production' run: | - yarn package:prod --target win32-x64 --out ${packagePath} + yarn package:prod --target win32-x64 --out ${{ env.packagePath }} - name: Build windows package (staging) if: inputs.environment == 'staging' run: | sed -i "s/^RI_APP_FOLDER_NAME=.*/RI_APP_FOLDER_NAME='.redis-for-vscode-stage'/" $envFile - yarn package:stage --target win32-x64 --out ${packagePath} + yarn package:stage --target win32-x64 --out ${{ env.packagePath }} - uses: actions/upload-artifact@v4 name: Upload extension artifact From da3e430ec768afbb2f53aed3b70ef107a7a00115 Mon Sep 17 00:00:00 2001 From: Egor Zalenski Date: Tue, 29 Oct 2024 11:26:43 +0100 Subject: [PATCH 7/9] test build --- .github/actions/install-all-build-libs/action.yml | 3 ++- .github/workflows/pipeline-build-macos.yml | 14 +++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/actions/install-all-build-libs/action.yml b/.github/actions/install-all-build-libs/action.yml index fb8ab13a..1bcf046d 100644 --- a/.github/actions/install-all-build-libs/action.yml +++ b/.github/actions/install-all-build-libs/action.yml @@ -6,9 +6,10 @@ runs: steps: # OS libraries - name: Setup Node - uses: actions/setup-node@v4.0.4 + uses: actions/setup-node@v4 with: node-version: '20.15' + cache: 'yarn' - name: Install dependencies for root package.js shell: bash diff --git a/.github/workflows/pipeline-build-macos.yml b/.github/workflows/pipeline-build-macos.yml index ec34afff..3ba446f1 100644 --- a/.github/workflows/pipeline-build-macos.yml +++ b/.github/workflows/pipeline-build-macos.yml @@ -39,12 +39,12 @@ jobs: with: arch: x64 - - name: Build macos package (staging) - if: inputs.environment == 'staging' + - name: Build macos x64 package (staging) + if: inputs.environment != 'production' run: | sed -i '' "s/^RI_APP_FOLDER_NAME=.*/RI_APP_FOLDER_NAME='.redis-for-vscode-stage'/" $envFile - yarn package:stage --target darwin-${{ inputs.target }} --out ${packagePath}-${{ inputs.target }}.vsix + yarn package:stage --target darwin-x64 --out ${packagePath}-x64.vsix - name: Build macos x64 package (production) if: inputs.environment == 'production' @@ -56,6 +56,14 @@ jobs: with: arch: arm64 + - name: Build macos arm64 package (staging) + if: inputs.environment != 'production' + run: | + sed -i '' "s/^RI_APP_FOLDER_NAME=.*/RI_APP_FOLDER_NAME='.redis-for-vscode-stage'/" $envFile + + yarn package:stage --target darwin-arm64 --out ${packagePath}-arm64.vsix + + - name: Build macos arm64 package (production) if: inputs.environment == 'production' run: | From 11c08c13024cc474c77d2b0204f86410c06257c1 Mon Sep 17 00:00:00 2001 From: Egor Zalenski Date: Tue, 29 Oct 2024 20:41:30 +0100 Subject: [PATCH 8/9] #RI-6233 - Migrate VS Code from circleCI to GitHub Actions --- .../actions/install-all-build-libs/action.yml | 1 - .github/e2e/test.app.sh | 1 + .github/workflows/build.yml | 2 +- .github/workflows/pipeline-build-linux.yml | 26 +++---------- .github/workflows/pipeline-build-macos.yml | 4 -- .github/workflows/pipeline-build-windows.yml | 4 -- .github/workflows/release-prod.yml | 2 +- .github/workflows/release-stage.yml | 2 +- .github/workflows/tests-e2e-linux.yml | 38 ++++++++----------- .github/workflows/tests.yml | 29 ++++++-------- tests/e2e/package.json | 2 +- tests/e2e/src/tests/settings/settings.e2e.ts | 4 +- tests/e2e/src/vscode.runner.ts | 2 +- 13 files changed, 41 insertions(+), 76 deletions(-) diff --git a/.github/actions/install-all-build-libs/action.yml b/.github/actions/install-all-build-libs/action.yml index 1bcf046d..3d8142dc 100644 --- a/.github/actions/install-all-build-libs/action.yml +++ b/.github/actions/install-all-build-libs/action.yml @@ -9,7 +9,6 @@ runs: uses: actions/setup-node@v4 with: node-version: '20.15' - cache: 'yarn' - name: Install dependencies for root package.js shell: bash diff --git a/.github/e2e/test.app.sh b/.github/e2e/test.app.sh index 44e32fbc..1f15126d 100755 --- a/.github/e2e/test.app.sh +++ b/.github/e2e/test.app.sh @@ -11,4 +11,5 @@ docker compose -f tests/e2e/rte.docker-compose.yml up --force-recreate -d -V # Run tests RI_SOCKETS_CORS=true \ +xvfb-run --auto-servernum \ yarn --cwd tests/e2e dotenv -e .ci.env yarn --cwd tests/e2e test:ci diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6dad42b2..44fc7e66 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Build +name: 🚀 Build on: # Manual trigger build diff --git a/.github/workflows/pipeline-build-linux.yml b/.github/workflows/pipeline-build-linux.yml index d760c0a9..8339b0c9 100644 --- a/.github/workflows/pipeline-build-linux.yml +++ b/.github/workflows/pipeline-build-linux.yml @@ -16,40 +16,24 @@ jobs: environment: ${{ inputs.environment }} steps: - # SSH - # - name: Setup upterm session - # uses: mxschmitt/action-tmate@v3 #1 better - - uses: actions/checkout@v4 + # SSH + # - name: Setup tmate session + # uses: mxschmitt/action-tmate@v3 + # with: + # detached: true - # - name: Install all libs and dependencies - # uses: ./.github/actions/install-all-build-libs - name: Setup Node uses: actions/setup-node@v4.0.4 with: node-version: '20.15' - # disable cache for windows - # https://github.com/actions/setup-node/issues/975 - cache: 'yarn' - - # - name: Setup Python - # uses: actions/setup-python@v5 - # with: - # python-version: '3.11' - name: Install dependencies for root package.js run: yarn install --frozen-lockfile - - # - run: rm -rf tsconfig.json - - name: Download backend uses: ./.github/actions/download-backend - # - run: ls -la ./scripts - # - run: yarn download:backend - # - run: yarn download:backend ${{ inputs.arch }} - - name: Set RI_SEGMENT_WRITE_KEY to .env file run: echo "RI_SEGMENT_WRITE_KEY='$RI_SEGMENT_WRITE_KEY'" >> $envFile diff --git a/.github/workflows/pipeline-build-macos.yml b/.github/workflows/pipeline-build-macos.yml index 3ba446f1..d2296cab 100644 --- a/.github/workflows/pipeline-build-macos.yml +++ b/.github/workflows/pipeline-build-macos.yml @@ -22,10 +22,6 @@ jobs: environment: ${{ inputs.environment }} steps: - # SSH - # - name: Setup upterm session - # uses: mxschmitt/action-tmate@v3 #1 better - - uses: actions/checkout@v4 - name: Install all libs and dependencies diff --git a/.github/workflows/pipeline-build-windows.yml b/.github/workflows/pipeline-build-windows.yml index 5d33f051..c8b40802 100644 --- a/.github/workflows/pipeline-build-windows.yml +++ b/.github/workflows/pipeline-build-windows.yml @@ -16,10 +16,6 @@ jobs: environment: ${{ inputs.environment }} steps: - # SSH debugging - # - name: Setup upterm session - # uses: mxschmitt/action-tmate@v3 #1 better - - uses: actions/checkout@v4 - name: Install all libs and dependencies diff --git a/.github/workflows/release-prod.yml b/.github/workflows/release-prod.yml index ab8c08f7..1a974588 100644 --- a/.github/workflows/release-prod.yml +++ b/.github/workflows/release-prod.yml @@ -1,4 +1,4 @@ -name: Release (prod) +name: ❗ Release (prod) on: push: diff --git a/.github/workflows/release-stage.yml b/.github/workflows/release-stage.yml index 28eaf1bd..8ea9f031 100644 --- a/.github/workflows/release-stage.yml +++ b/.github/workflows/release-stage.yml @@ -1,4 +1,4 @@ -name: Release (stage) +name: 📖 Release (stage) on: push: diff --git a/.github/workflows/tests-e2e-linux.yml b/.github/workflows/tests-e2e-linux.yml index cf6a2294..b176d34e 100644 --- a/.github/workflows/tests-e2e-linux.yml +++ b/.github/workflows/tests-e2e-linux.yml @@ -10,34 +10,25 @@ on: env: SLACK_TEST_REPORT_KEY: ${{ secrets.SLACK_TEST_REPORT_KEY }} + TEST_BIG_DB_DUMP: ${{ secrets.TEST_BIG_DB_DUMP }} jobs: e2e-linux-tests: runs-on: ubuntu-latest name: E2E tests - container: - image: docker:latest - options: --privileged - volumes: - - /usr/src/app/results:/usr/src/app/results - - /usr/src/app/report:/usr/src/app/report strategy: fail-fast: false matrix: # Number of threads to run tests - # parallel: [0, 1, 2, 3] - parallel: [0] + parallel: [0, 1, 2, 3] steps: - uses: actions/checkout@v4 - # - name: Setup repository - # run: git config --global --add safe.directory /__w/RedisInsight/Redis-for-VS-Code - - - name: Start Xvfb - run: | - apt-get install -y xvfb net-tools - Xvfb :99 -screen 0 1920x1080x24 & + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: '20.15' - name: Download linux artifact uses: actions/download-artifact@v4 @@ -48,6 +39,7 @@ jobs: - name: Setup e2e tests working-directory: ./tests/e2e run: | + npm install -g @vscode/vsce yarn install yarn compile ls -R dist/tests/ @@ -55,7 +47,7 @@ jobs: - name: Generate short list of the test files working-directory: ./tests/e2e run: | - testFiles=$(find tests -type f -name '*.e2e.js' | sort | awk "NR % 4 == ${{ matrix.parallel }}") + testFiles=$(find dist -type f -name '*.e2e.js' | sort | awk "NR % 1 == ${{ matrix.parallel }}") echo $testFiles # Multi-Line value @@ -67,12 +59,12 @@ jobs: run: | .github/e2e/test.app.sh - - name: Upload Test Report + - name: Upload Test Mocha Report uses: actions/upload-artifact@v4 if: always() with: - name: report-linux-node-${{ matrix.parallel }} - path: /usr/src/app/report + name: mocha-report-linux-node-${{ matrix.parallel }} + path: tests/e2e/mochawesome-report - name: Send report to Slack if: inputs.report && always() @@ -85,7 +77,7 @@ jobs: if: always() with: name: 'Test results: E2E (linux) ${{ matrix.parallel }}th node' - path: /usr/src/app/results/results.xml + path: tests/e2e/mochawesome-report/junit-report.xml reporter: java-junit list-tests: 'failed' list-suites: 'failed' @@ -99,6 +91,8 @@ jobs: id: merge-artifacts uses: actions/upload-artifact/merge@v4 with: - name: report-e2e-linux - pattern: report-linux-node-* + name: mocha-report-linux + pattern: mocha-report-linux-node-* + separate-directories: true delete-merged: true + retention-days: 5 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1da788de..0ba213d9 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,4 +1,4 @@ -name: Tests +name: ✅ Tests on: push: @@ -16,25 +16,20 @@ jobs: secrets: inherit # E2E Approve - # e2e-approve: - # runs-on: ubuntu-latest - # timeout-minutes: 60 - # if: startsWith(github.ref_name, 'e2e/') - # environment: ${{ startsWith(github.ref_name, 'e2e/') && 'e2e-approve' || 'staging' }} - # name: Approve E2E tests - # steps: - # - uses: actions/checkout@v4 + e2e-approve: + runs-on: ubuntu-latest + timeout-minutes: 60 + if: startsWith(github.ref_name, 'e2e/') + environment: ${{ startsWith(github.ref_name, 'e2e/') && 'e2e-approve' || 'staging' }} + name: Approve E2E tests # E2E Docker - build: - uses: ./.github/workflows/build.yml + build-linux: + uses: ./.github/workflows/pipeline-build-linux.yml + needs: e2e-approve secrets: inherit - # build-linux: - # uses: ./.github/workflows/pipeline-build-linux.yml - # needs: e2e-approve - # secrets: inherit - e2e-linux-tests: - needs: build + e2e-linux-test: + needs: build-linux uses: ./.github/workflows/tests-e2e-linux.yml secrets: inherit diff --git a/tests/e2e/package.json b/tests/e2e/package.json index 9971c44c..ad323220 100644 --- a/tests/e2e/package.json +++ b/tests/e2e/package.json @@ -9,7 +9,7 @@ "install:vs-code": "extest get-vscode -s ./test-resources", "install:chrome-driver": "extest get-chromedriver -s ./test-resources", "install:deps": "yarn install:vs-code && yarn install:chrome-driver", - "install:extension": "extest install-vsix -f redis-insight-vsc-plugin.vsix -e ./test-extensions", + "install:extension": "extest install-vsix -f redis-for-vscode-extension.vsix -e ./test-extensions", "test": "yarn run compile && dotenv -e .env extest run-tests dist/tests/setup.js dist/tests/**/*.js --code_settings settings.json -r . --extensions_dir ./test-extensions", "test:ci": "yarn compile && dotenv -e .env ts-node ./src/vscode.runner.ts", "test:ci:clear": "rimraf ./test-extensions && yarn --cwd ../../ package:prod && yarn compile && dotenv -e .ci.env ts-node ./src/vscode.runner.ts" diff --git a/tests/e2e/src/tests/settings/settings.e2e.ts b/tests/e2e/src/tests/settings/settings.e2e.ts index 1788e875..93729694 100644 --- a/tests/e2e/src/tests/settings/settings.e2e.ts +++ b/tests/e2e/src/tests/settings/settings.e2e.ts @@ -89,8 +89,8 @@ describe('Settings', () => { await ButtonActions.clickElement(InputWithButtons.cancelInput) // Check the previous delimiter value expect(await InputActions.getInputValue(settingsView.delimiterInput)).eql( - ':', - 'Default delimiter not applied', + 'uaoeu:', + 'Default uoeuaoe udelimiter not applied', ) // Change delimiter diff --git a/tests/e2e/src/vscode.runner.ts b/tests/e2e/src/vscode.runner.ts index daa9f6cb..00f3537c 100644 --- a/tests/e2e/src/vscode.runner.ts +++ b/tests/e2e/src/vscode.runner.ts @@ -59,7 +59,7 @@ import { VScodeScripts } from './helpers/scripts/vscodeScripts' let testFilesEnv: string | string[] = process.env.TEST_FILES! if (process.env.TEST_FILES) { testFilesEnv = process.env.TEST_FILES.split('\n').map(file => file.trim()).map((file) => { - return path.join(__dirname, '..', 'dist', file) + return path.join(__dirname, '..', file) }) // Always prepend setup.js From cd23d8d620e1d3963104b07d5aaa1907947cce82 Mon Sep 17 00:00:00 2001 From: Egor Zalenski Date: Tue, 29 Oct 2024 20:44:01 +0100 Subject: [PATCH 9/9] #RI-6233 - Migrate VS Code from circleCI to GitHub Actions --- tests/e2e/src/tests/settings/settings.e2e.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/e2e/src/tests/settings/settings.e2e.ts b/tests/e2e/src/tests/settings/settings.e2e.ts index 93729694..1788e875 100644 --- a/tests/e2e/src/tests/settings/settings.e2e.ts +++ b/tests/e2e/src/tests/settings/settings.e2e.ts @@ -89,8 +89,8 @@ describe('Settings', () => { await ButtonActions.clickElement(InputWithButtons.cancelInput) // Check the previous delimiter value expect(await InputActions.getInputValue(settingsView.delimiterInput)).eql( - 'uaoeu:', - 'Default uoeuaoe udelimiter not applied', + ':', + 'Default delimiter not applied', ) // Change delimiter