Skip to content

Commit

Permalink
feat: print URL to console in hyperlink
Browse files Browse the repository at this point in the history
  • Loading branch information
cybersokari committed Dec 8, 2024
1 parent 8f7ed2e commit 0666c7e
Show file tree
Hide file tree
Showing 9 changed files with 113 additions and 23 deletions.
21 changes: 18 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,23 +94,31 @@ jobs:
sokari/allure-docker-deploy:latest
```
___
#### 2. Generate Allure results
Add a step that outputs Allure result files to `/allure-results` path in the workflow.

___

#### 3. Run the Workflow:
Push your changes to the main branch and let GitHub Actions do the rest!
___

#### 4. View Report information:
Check the job summary in GitHub Actions for the report URL.

<div style="text-align: left"><img src="assets/example-github-summary.png" alt="URL preview in GitHub Actions summary"></div>

___

#### 5. Get notified in Slack
Add SLACK_TOKEN and SLACK_CHANNEL_ID as environment variable in the docker run command to receipt job
completion notifications in Slack.

<div style="text-align: left"><img src="assets/slack-bot.png" alt="URL preview in GitHub Actions summary"></div>

___

#### 6. View your test result files on the Firebase Developer console

Expand All @@ -128,11 +136,15 @@ Tips
2. Configure `WEBSITE_EXPIRES` to manage the duration of hosted reports.
3. Mount `$GITHUB_STEP_SUMMARY` to display the test report URL in GitHub Actions job summaries.

___

### 2. For local test runs
#### 1. Pull the Docker Image
```bash
docker pull sokari/allure-docker-deploy:latest
```
___

#### 2. Run the Container
```shell
docker run -d \
Expand All @@ -145,6 +157,8 @@ docker run -d \
-v /path/to/gcp-key.json:/credentials/key.json \
sokari/allure-docker-deploy
```
___

##### 3. You can also use `docker-compose.yaml`:
```yaml
services:
Expand All @@ -164,11 +178,12 @@ services:
WATCH_MODE: true
TTL_SECS: 60
```
___

#### 4. View test report URL in console
<div style="text-align: left"><img src="assets/clean-console-add.png" height="300" alt="Firebase CLI console output"></div>

#### 4. Receive test report URL in console
<div style="text-align: left"><img src="assets/ci-report-url-ss.png" height="300" alt="Firebase CLI console output"></div>

___

## 🔑 **Key Features**
* **Cloud Storage**: Automatically backs up test results to Google Cloud Storage.
Expand Down
Binary file added assets/clean-console-add.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ if [ -n "$TTL_SECS" ]; then
fi
fi
echo 'Starting the app'
node /app/lib/index.js
node --disable-warning=ExperimentalWarning /app/lib/index.js
2 changes: 0 additions & 2 deletions worker/app/batch-processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ export class BatchProcessor {
// Process only up to `maxQueueSize` files in each batch
const filesToProcess = this.fileQueue.splice(0, this.maxQueueSize);

console.log(`Processing ${filesToProcess.length} files...`);

try {
const promises: Promise<any>[] = [];
if (websiteId) {
Expand Down
6 changes: 3 additions & 3 deletions worker/app/cloud-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class CloudStorage {
destinationFilePath = path.basename(filePath);
}
try {
console.log(`Uploading ${destinationFilePath} to storage`)
// console.log(`Uploading ${destinationFilePath} to storage`)
await CloudStorage.bucket.upload(filePath, {
validation: !DEBUG,
destination: `${storageHomeDir}/${destinationFilePath}`,
Expand All @@ -58,7 +58,7 @@ export class CloudStorage {
try {
const [files] = await CloudStorage.bucket.getFiles({prefix: `${storageHomeDir}/`});
if (!files.length) {
console.log(`No files found in folder: ${storageHomeDir}/`);
console.log('No files to process from CloudStorage');
return;
}
await fs.mkdir(STAGING_PATH, {recursive: true}); // recursive, dont throw if exist
Expand All @@ -69,10 +69,10 @@ export class CloudStorage {
// Remove the preceding storageHomeDir path from the downloaded file
const destination = path.join(STAGING_PATH, file.name.replace(`${storageHomeDir}/`, ''));
await file.download({destination, validation: !DEBUG});
console.log(`Downloaded ${file.name}`);
}))
}
await Promise.all(downloadPromises);
console.log(`${files.length} files downloaded CloudStorage`);
} catch (error) {
console.error('Download error:', error);
}
Expand Down
12 changes: 8 additions & 4 deletions worker/app/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@ import * as fsSync from 'fs'
import * as fs from 'fs/promises'
import * as path from "node:path";
import util from "node:util";

const exec = util.promisify(require('child_process').exec)
import {DEBUG, websiteId} from "../index";
import {StringBuilder} from "./string-builder";
import credential from "./credential";

import ansiEscapes from 'ansi-escapes';
import chalk from "chalk";


export async function* getAllFilesStream(dir: string): AsyncGenerator<string> {
const entries = await fs.readdir(dir, { withFileTypes: true });
const entries = await fs.readdir(dir, {withFileTypes: true});
for (const entry of entries) {
const fullPath = path.join(dir, entry.name);
if (entry.isDirectory()) {
Expand All @@ -30,7 +32,7 @@ export async function* getAllFilesStream(dir: string): AsyncGenerator<string> {
export function validateWebsiteExpires(expires: string): boolean {

const length = expires.length
if(length < 2 || length > 3){
if (length < 2 || length > 3) {
return false;
}

Expand Down Expand Up @@ -143,7 +145,9 @@ export async function publishToFireBaseHosting(configParentDir: string): Promise

if (match && match[2]) {
const url = match[2]
console.log(`Allure test report URL: ${url}`)

console.log('Allure test report URL')
console.log(ansiEscapes.link(chalk.blue(url), url));
return url as string
} else {
console.warn('Could not parse URL from hosting.')
Expand Down
89 changes: 80 additions & 9 deletions worker/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
"dependencies": {
"@slack/web-api": "^7.8.0",
"allure-commandline": "^2.32.0",
"ansi-escapes": "^7.0.0",
"async-mutex": "^0.5.0",
"chalk": "^5.3.0",
"chokidar": "^4.0.1",
"firebase-admin": "^13.0.1",
"p-limit": "^6.1.0"
Expand Down
2 changes: 1 addition & 1 deletion worker/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"outDir": "lib",
"sourceMap": true,
"strict": true,
"target": "es2017",
"target": "es2020",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true
},
Expand Down

0 comments on commit 0666c7e

Please sign in to comment.