Skip to content

Commit

Permalink
use GitHub mounted directory
Browse files Browse the repository at this point in the history
  • Loading branch information
cybersokari committed Dec 16, 2024
1 parent acbbf24 commit a18adc8
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
SLACK_TOKEN: ${{secrets.SLACK_TOKEN}}
GOOGLE_CREDENTIALS_JSON: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
with:
allure_results_path: '${{ github.workspace }}/assets/allure-results'
allure_results_path: '/assets/allure-results'
storage_bucket: ${{github.event.inputs.storage-bucket}}
website_id: ${{ github.event.inputs.website-id }}
website_expires: ${{github.event.inputs.website-expires}}
Expand Down
4 changes: 3 additions & 1 deletion packages/action/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ArgsInterface } from "@allure/shared";
import { ActionsCredentials } from "./credentials.js";
import * as path from "node:path";

export function getArgs(credentials: ActionsCredentials): ArgsInterface {
const keepHistory = process.env.KEEP_HISTORY === "true";
Expand All @@ -8,6 +9,7 @@ export function getArgs(credentials: ActionsCredentials): ArgsInterface {
const showHistory = process.env.SHOW_HISTORY === "true";
const showRetries = process.env.SHOW_RETRIES === "true";
const downloadRequired = showRetries || showHistory;
const resultsPath = path.normalize(`/github/workspace/${process.env.ALLURE_RESULTS_PATH!}`);

return {
firebaseProjectId: credentials.projectId,
Expand All @@ -18,7 +20,7 @@ export function getArgs(credentials: ActionsCredentials): ArgsInterface {
keepResults: keepResults,
ARCHIVE_DIR: '/app/archive',
HOME_DIR: "/app",
MOUNTED_PATH: process.env.ALLURE_RESULTS_PATH!,
RESULTS_PATH: resultsPath,
REPORTS_DIR: "/app/allure-reports",
RESULTS_STAGING_PATH: "/app/allure-results",
fileProcessingConcurrency: 10,
Expand Down
2 changes: 1 addition & 1 deletion packages/action/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function main() {
process.exit(1)
}
const args = getArgs(creds)
if(!args.MOUNTED_PATH){
if(!args.RESULTS_PATH){
console.error('allure_results_path is required')
process.exit(1)
}
Expand Down
2 changes: 1 addition & 1 deletion packages/docker/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function main(): void {
args = {
ARCHIVE_DIR: ARCHIVE_DIR,
HOME_DIR: HOME_DIR,
MOUNTED_PATH: MOUNTED_PATH,
RESULTS_PATH: MOUNTED_PATH,
REPORTS_DIR: REPORTS_DIR,
RESULTS_STAGING_PATH: RESULTS_STAGING_PATH,
fileProcessingConcurrency: fileProcessingConcurrency,
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/src/features/allure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class Allure {
async stageFilesFromMount(): Promise<void> {
// Ensure staging directory exists and fetch list
const [files] = await Promise.all([
fs.readdir(this.args.MOUNTED_PATH, { withFileTypes: true }), // Get files info
fs.readdir(this.args.RESULTS_PATH, { withFileTypes: true }), // Get files info
fs.mkdir(this.args.RESULTS_STAGING_PATH, { recursive: true }) // Create staging if it doesn't exist
]);

Expand Down Expand Up @@ -73,7 +73,7 @@ export class Allure {
}

private async copyFile(file: Dirent): Promise<void> {
const fileToCopy = path.join(this.args.MOUNTED_PATH, file.name);
const fileToCopy = path.join(this.args.RESULTS_PATH, file.name);
const destination = path.join(this.args.RESULTS_STAGING_PATH, file.name);
await fs.cp(fileToCopy, destination, { force: false, errorOnExist: false });
}
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/src/features/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ export class Storage {
const foldersToBackup: { path: string, destination?: string }[] = []
const foldersToCount = []
if (this.args.keepResults) {
foldersToBackup.push({path: this.args.MOUNTED_PATH})
foldersToCount.push(this.args.MOUNTED_PATH)
foldersToBackup.push({path: this.args.RESULTS_PATH})
foldersToCount.push(this.args.RESULTS_PATH)
}
if (this.args.websiteId && this.args.keepHistory) {
const historyFolder = `${this.args.REPORTS_DIR}/history`
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/interfaces/args.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export interface ArgsInterface {
RESULTS_STAGING_PATH: string;
ARCHIVE_DIR: string;
REPORTS_DIR: string;
MOUNTED_PATH: string;
RESULTS_PATH: string;
fileProcessingConcurrency: number;
firebaseProjectId: string;
uploadRequired: boolean;
Expand Down

0 comments on commit a18adc8

Please sign in to comment.