- fix formatting
- apply some smaller fixes - enable cache for 1 gitea test (no need to use API) - do not cache and export token in cache - speed up main.test.ts
This commit is contained in:
+2
-1
@@ -14,9 +14,10 @@ async function run(): Promise<void> {
|
||||
function isSupportedPlatform(type: string): type is keyof typeof supportedPlatform {
|
||||
return type in supportedPlatform
|
||||
}
|
||||
core.setOutput('failed', false) // mark the action not failed by default
|
||||
|
||||
core.setOutput('failed', false) // mark the action not failed by default
|
||||
core.startGroup(`📘 Reading input values`)
|
||||
|
||||
try {
|
||||
// read in path specification, resolve github workspace, and repo path
|
||||
const platform = core.getInput('platform') || 'github'
|
||||
|
||||
@@ -194,7 +194,7 @@ export class Tags {
|
||||
|
||||
/*
|
||||
* Uses the provided filter (if available) to filter out any tags not currently relevant.
|
||||
* https://tagTransformers/mikepenz/release-changelog-builder-action/issues/566
|
||||
* https://github.com/mikepenz/release-changelog-builder-action/issues/566
|
||||
*/
|
||||
export function filterTags(tags: TagInfo[], tagResolver: TagResolver): TagInfo[] {
|
||||
const filter = tagResolver.filter
|
||||
|
||||
@@ -21,7 +21,7 @@ export interface ReleaseNotesOptions {
|
||||
fetchReviews: boolean // defines if the action should fetch the reviews for the PR.
|
||||
commitMode: boolean // defines if we use the alternative commit based mode. note: this is only partially supported
|
||||
configuration: Configuration // the configuration as defined in `configuration.ts`
|
||||
repositoryUtils: BaseRepository
|
||||
repositoryUtils: BaseRepository // the repository implementation used to generate the changelog
|
||||
}
|
||||
|
||||
export interface Data {
|
||||
|
||||
@@ -46,7 +46,7 @@ export abstract class BaseRepository {
|
||||
|
||||
abstract getReviews(owner: string, repo: string, pr: PullRequestInfo): Promise<void>
|
||||
|
||||
protected async getTagByCreateTime(repositoryPath: string, tagInfo: TagInfo) {
|
||||
protected async getTagByCreateTime(repositoryPath: string, tagInfo: TagInfo): Promise<TagInfo> {
|
||||
core.info(`⚠️ No release information found for ${tagInfo.name}, trying to retrieve tag creation time as fallback.`)
|
||||
const gitHelper = await createCommandManager(repositoryPath)
|
||||
const creationTimeString = await gitHelper.tagCreation(tagInfo.name)
|
||||
|
||||
@@ -2,12 +2,10 @@ import {BaseRepository} from './BaseRepository'
|
||||
import {TagInfo} from '../pr-collector/tags'
|
||||
import {CommentInfo, PullRequestInfo} from '../pr-collector/pullRequests'
|
||||
import {DiffInfo} from '../pr-collector/commits'
|
||||
import {Api, PullRequest, PullReview} from 'gitea-js'
|
||||
import {Api, PullRequest, PullReview, giteaApi} from 'gitea-js'
|
||||
import moment from 'moment'
|
||||
import * as core from '@actions/core'
|
||||
import {createCommandManager} from '../pr-collector/gitHelper'
|
||||
import { giteaApi } from 'gitea-js';
|
||||
import fetch from 'cross-fetch';
|
||||
interface Pulls {
|
||||
closed: PullRequest[]
|
||||
open: PullRequest[]
|
||||
@@ -23,9 +21,8 @@ export class GiteaRepository extends BaseRepository {
|
||||
constructor(token: string, url: string | undefined, repositoryPath: string) {
|
||||
super(token, url, repositoryPath)
|
||||
this.url = url || this.defaultUrl
|
||||
this.api = giteaApi(this.url,{
|
||||
token:token,
|
||||
customFetch: fetch
|
||||
this.api = giteaApi(this.url, {
|
||||
token
|
||||
})
|
||||
}
|
||||
|
||||
@@ -75,7 +72,6 @@ export class GiteaRepository extends BaseRepository {
|
||||
labels: pr.labels?.map(label => label.name) as string[],
|
||||
milestone: pr.milestone?.title || '',
|
||||
body: pr.body || '',
|
||||
|
||||
assignees: pr.assignees?.map(user => user.full_name) as string[],
|
||||
requestedReviewers: pr.requested_reviewers?.map(user => user.full_name) as string[],
|
||||
approvedReviewers: [],
|
||||
@@ -100,7 +96,7 @@ export class GiteaRepository extends BaseRepository {
|
||||
|
||||
for (const line of diffStatLines) {
|
||||
// Extract the addition and deletion counts from each line of the git diff output
|
||||
const match = line.match(/(\d+) insertions?\(\+\), (\d+) deletions?\(\-\)/)
|
||||
const match = line.match(/(\d+) insertions?\(\+\), (\d+) deletions?\(-\)/)
|
||||
if (match) {
|
||||
additionCount += parseInt(match[1], 10)
|
||||
deletionCount += parseInt(match[2], 10)
|
||||
@@ -121,8 +117,9 @@ export class GiteaRepository extends BaseRepository {
|
||||
const commitLogs = log.stdout.trim().split('\n')
|
||||
|
||||
// Process commit logs
|
||||
const commitInfo = commitLogs.map(log => {
|
||||
const [sha, authorName, authorEmail, authorDate, committerName, committerEmail, committerDate, subject] = log.split('||||')
|
||||
const commitInfo = commitLogs.map(commitLog => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const [sha, authorName, authorEmail, authorDate, committerName, committerEmail, committerDate, subject] = commitLog.split('||||')
|
||||
return {
|
||||
sha,
|
||||
summary: subject,
|
||||
@@ -150,7 +147,7 @@ export class GiteaRepository extends BaseRepository {
|
||||
open: []
|
||||
}
|
||||
|
||||
private async getAllPullRequest(owner: string, repo: string, state: 'closed' | 'open', maxPullRequests: number) {
|
||||
private async getAllPullRequest(owner: string, repo: string, state: 'closed' | 'open', maxPullRequests: number): Promise<void> {
|
||||
if (GiteaRepository.pulls[state].length === 0) {
|
||||
let page = 1
|
||||
let count = 0
|
||||
@@ -164,8 +161,8 @@ export class GiteaRepository extends BaseRepository {
|
||||
})
|
||||
if (response.error === null) {
|
||||
GiteaRepository.pulls[state].push(...response.data)
|
||||
}else{
|
||||
core.error(`ℹ️ Some errors. ${response.error!!.message}`)
|
||||
} else {
|
||||
core.error(`ℹ️ Some errors. ${response.error.message}`)
|
||||
}
|
||||
page++
|
||||
count += response.data.length
|
||||
@@ -184,7 +181,7 @@ export class GiteaRepository extends BaseRepository {
|
||||
}
|
||||
}
|
||||
|
||||
core.debug(`⚠️ No more PRs retrieved from API. Fetched so far: ${mergedPRs.length}`)
|
||||
core.debug(`Completed fetching PRs from API. Fetched: ${mergedPRs.length}`)
|
||||
|
||||
return mergedPRs
|
||||
}
|
||||
@@ -206,9 +203,8 @@ export class GiteaRepository extends BaseRepository {
|
||||
for (const comment of response.data) {
|
||||
prReviews.push(this.mapComment(comment))
|
||||
}
|
||||
}else{
|
||||
|
||||
core.error(`ℹ️ Some errors. ${response.error!!.message}`)
|
||||
} else {
|
||||
core.error(`ℹ️ Some errors. ${response.error.message}`)
|
||||
}
|
||||
pr.reviews = prReviews
|
||||
}
|
||||
@@ -235,9 +231,8 @@ export class GiteaRepository extends BaseRepository {
|
||||
commit: tag.commit?.sha
|
||||
})
|
||||
}
|
||||
}else{
|
||||
|
||||
core.error(`ℹ️ Some errors. ${response.error!!.message}`)
|
||||
} else {
|
||||
core.error(`ℹ️ Some errors. ${response.error.message}`)
|
||||
}
|
||||
core.info(`ℹ️ Found ${tagsInfo.length} (fetching max: ${maxTagsToFetch}) tags from the GitHub API for ${owner}/${repo}`)
|
||||
return tagsInfo
|
||||
|
||||
+9
-1
@@ -41,13 +41,21 @@ export function writeCacheData(data: Data, cacheOutput: string | null): void {
|
||||
}
|
||||
|
||||
try {
|
||||
fs.writeFileSync(cacheFile, JSON.stringify(data))
|
||||
// use replacer to not cache the repositoryUtils (as that would contain token information)
|
||||
fs.writeFileSync(cacheFile, JSON.stringify(data, replacer))
|
||||
core.setOutput(`cache`, cacheFile)
|
||||
} catch (error) {
|
||||
core.warning(`Failed to write cache file. (${error})`)
|
||||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
function replacer(key: string, value: any): any {
|
||||
if (key === 'repositoryUtils') return undefined
|
||||
if (key === 'token') return undefined
|
||||
else return value
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the exported information from a previous run of the `release-changelog-builder-action`.
|
||||
* If available, return a [ReleaseNotesData].
|
||||
|
||||
Reference in New Issue
Block a user