Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
ThisIsManta committed Oct 24, 2023
1 parent 15e3b59 commit dfca34f
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 52 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,16 @@ jobs:

- if: ${{ always() }}
run: echo "${{ steps.cache.outputs.cache-hit }}"

parallel:
name: ${{ matrix.number }}
runs-on: ubuntu-latest
strategy:
matrix:
number: [1, 2]
steps:
- uses: actions/checkout@v3

- uses: ./save
with:
cache-key: parallel-${{ github.run_number }}
2 changes: 1 addition & 1 deletion restore/main.js

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions restore/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ async function run() {
const result = require(resultFilePath)
console.log('status =', result.status)

const ending = result.url ? (' at ' + result.url) : ' previously.'

if (result.status === 'failure') {
core.setFailed('This job has failed at ' + result.url)
core.setFailed('This job has failed' + ending)
} else {
core.info('This job has succeeded at ' + result.url)
core.info('This job has succeeded' + ending)
}
}
}
Expand Down
84 changes: 42 additions & 42 deletions save/main.js

Large diffs are not rendered by default.

13 changes: 6 additions & 7 deletions save/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { mkdirp } from 'mkdirp'
const resultFilePath = '/tmp/result.json'

async function run() {

const status = core.getInput('job-status', { required: true })
console.log('status =', status)

Expand All @@ -24,15 +25,13 @@ async function run() {
return { data: { jobs: [] } }
})

// Do not use `job.steps[*].conclusion` from GitHub API as it does not reflect the latest step progress.
const job = jobs.find(job => job.name === github.context.job)
if (!job) {
core.warning(`Could not resolve job ID from job name "${github.context.job}".`)
}
// Do not match `job.name` as it can be different in matrix
const job = jobs.find(job => job.runner_name === process.env.RUNNER_NAME)
core.debug('job = ' + JSON.stringify(job, null, 2))

const result = {
status,
url: `${github.context.serverUrl}/${github.context.repo.owner}/${github.context.repo.repo}/actions/runs/${github.context.runId}` + (job ? `/job/${job.id}` : ''),
status, // Do not use `job.steps[*].conclusion` from GitHub API as it does not reflect the most recent progress.
url: job?.html_url || `${github.context.serverUrl}/${github.context.repo.owner}/${github.context.repo.repo}/actions/runs/${github.context.runId}`,
}

await mkdirp(path.dirname(resultFilePath))
Expand Down

0 comments on commit dfca34f

Please sign in to comment.