Skip to content

Try using cygport vars action #47

Try using cygport vars action

Try using cygport vars action #47

name: Test workflows
on: [push, pull_request]
# Avoid multiple caching tests stomping over each other
concurrency: mainline-cache-${{ github.sha }}
jobs:
# We need to start with a clean slate for this SHA, so we can distinguish
# between caches created in different ref contexts.
clear-caches:
name: Clear any existing caches
permissions:
actions: write
runs-on: ubuntu-latest
steps:
- name: Clear existing caches for this commit
uses: actions/github-script@v6
with:
script: |
try {
const response = await github.rest.actions.deleteActionsCacheByKey({
owner: context.repo.owner,
repo: context.repo.repo,
key: `mainline-build-${context.sha}`
});
core.info(`Deleted ${response.data.total_count} caches`);
if (core.isDebug()) {
for (const cache of response.data.actions_caches) {
core.debug(`Deleted cache ID ${cache.id}, ref ${cache.ref}, key ${cache.key}, version ${cache.version}`);
}
}
} catch(e) {
if (e.response.status == 404) {
core.info('No caches to delete');
return;
}
throw(e); // Not the error we were looking for
}
mainline:
name: Basic mainline test
needs: clear-caches
uses: ./.github/workflows/build-test.yml

Check failure on line 43 in .github/workflows/workflow-tests.yml

View workflow run for this annotation

GitHub Actions / Test workflows

Invalid workflow file

The workflow is not valid. In .github/workflows/workflow-tests.yml (Line: 43, Col: 11): Error from called workflow cygporter/workflows/.github/workflows/build-test.yml@736a718b822d5b8bcd227142e5a9f150e2f3c0eb (Line: 87, Col: 13): A sequence was not expected
with:
cygport_file: t/mainline.cygport
ensure-build-cache:
name: Check there's a current build cache
needs: mainline
runs-on: ubuntu-latest
steps:
- name: Check number of caches for the mainline build
id: check
uses: actions/github-script@v6
with:
script: |
const response = await github.rest.actions.getActionsCacheList({
owner: context.repo.owner,
repo: context.repo.repo,
key: 'mainline-build-' + context.sha
});
core.info(`Found ${response.data.total_count} caches`);
if (response.data.total_count != 1) {
core.setFailed(`Expected one cache entry, found ${response.data.total_count}.`);
if (response.data.total_count > 0) {
core.startGroup('Cache list');
response.data.actions_caches.forEach(cache =>
core.info(`cache id: ${cache.id}, ref: ${cache.ref}, key: ${cache.key}, version: ${cache.version}`));
core.endGroup();
}
}
mainline-use-cache:
name: Check a build won't create a new cache unnecessarily
needs: mainline
uses: ./.github/workflows/build-test.yml
with:
cygport_file: t/mainline.cygport
ensure-cache-used:
name: Check the build did use the extant cache
needs: mainline-use-cache
runs-on: ubuntu-latest
steps:
- name: Error if cache unused
if: needs.mainline-use-cache.outputs.cache-found != 'true'
run: |
echo '::error title=Cache not used::Cache reportedly not used for rebuild'
exit 1