Skip to content

Modify expect-error input checking to fix errors on main #1190

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 17, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/debug-artifacts-failure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ jobs:
timeout-minutes: 45
runs-on: ${{ matrix.os }}
steps:
- name: Dump GitHub event
run: cat "${GITHUB_EVENT_PATH}"
- name: Check out repository
uses: actions/checkout@v3
- name: Prepare test
Expand Down
18 changes: 1 addition & 17 deletions lib/actions-util.js

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

2 changes: 1 addition & 1 deletion lib/actions-util.js.map

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions lib/analyze-action.js

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

2 changes: 1 addition & 1 deletion lib/analyze-action.js.map

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

15 changes: 0 additions & 15 deletions src/actions-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import * as safeWhich from "@chrisgavin/safe-which";
import * as yaml from "js-yaml";

import * as api from "./api-client";
import { CODEQL_DEFAULT_ACTION_REPOSITORY } from "./codeql";
import { Config } from "./config-utils";
import * as sharedEnv from "./shared-environment";
import {
Expand Down Expand Up @@ -901,17 +900,3 @@ export async function printDebugLogs(config: Config) {
walkLogFiles(logsDirectory);
}
}

// Returns whether workflow kicked off by codeql-action repo itself,
// or a fork of it.
export function isAnalyzingCodeQLActionRepoOrFork(): boolean {
const codeQLActionRepoUrl = `https://api.github.com/repos/${CODEQL_DEFAULT_ACTION_REPOSITORY}`;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm actually I think the problem was that this should have been https://github.com/${CODEQL_DEFAULT_ACTION_REPOSITORY}. But I have a mild preference for the new solution since that works with the clone that isn't a fork case.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the new solution seems reasonable to me.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried this URL at first but it seemed like it was the api.github.com one when I was testing the PR check locally. I guess it's probably different in main vs in a PR check?

I think your solution is better in any case as well 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh you're totally right — it's api.github.com on a pull_request trigger, and github.com on a push trigger.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh interesting.. I guess it would've worked if we'd checked for either. Do you mind pointing me to where you found this in the documentation? (if you found it there ha)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just triggered some Actions to find out — see https://github.com/github/codeql-action/runs/7917327160?check_suite_focus=true where it's github.com on push and https://github.com/github/codeql-action/runs/7916384170?check_suite_focus=true where it's api.github.com on ready_for_review.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yep, I see, the Dump GitHub event step gives it away. Thanks!

const repo = getWorkflowEvent()?.repository;
if (repo?.url === codeQLActionRepoUrl) {
return true;
}
if (repo?.fork && repo?.parent?.url === codeQLActionRepoUrl) {
return true;
}
return false;
}
5 changes: 2 additions & 3 deletions src/analyze-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,11 @@ export async function sendStatusReport(
}
}

// `expect-error` should only be set to any value by the
// codeql-action repo or a fork of it.
// `expect-error` should only be set to a non-false value by the CodeQL Action PR checks.
function hasBadExpectErrorInput(): boolean {
return (
actionsUtil.getOptionalInput("expect-error") !== "false" &&
!actionsUtil.isAnalyzingCodeQLActionRepoOrFork()
!util.isInTestMode()
);
}

Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy