Skip to content
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

📖 meh #35

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions .github/workflows/ci-global.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ on:
- "main"

pull_request:
paths-ignore:
- "docs/**"
- "hack/**"
- "*.md"
branches:
- "main"

Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/ci-image-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ name: CI (test image build for a PR with build related changes)

on:
pull_request:
paths-ignore:
- "docs/**"
- "hack/**"
- "*.md"
branches:
- "main"
- "release-*"
Expand Down
59 changes: 55 additions & 4 deletions .github/workflows/ci-repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,77 @@ concurrency:
cancel-in-progress: true

jobs:
unit-test-lookup-image:
unit-test-lookup:
runs-on: ubuntu-latest
outputs:
builder-image: ${{ steps.grepBuilder.outputs.builder }}
should-test: ${{ steps.check-changes.outputs.should-test }}

steps:
- uses: actions/checkout@v4

- name: Lookup builder image from the project's Dockerfile
id: grepBuilder
run: |
builder=$(grep 'as builder' Dockerfile | sed -e 's/^FROM \(.*\) as builder$/\1/')
echo "Builder image: \`$builder\`" >> "$GITHUB_STEP_SUMMARY"
echo "builder=$builder" >> "$GITHUB_OUTPUT"

- name: Did docs and hacks change?
id: docs-and-hacks
uses: tj-actions/changed-files@v44
with:
files: |
docs/**
hack/**
*.md

- name: Check if only docs and hacks changes have been made in a PR
id: check-changes
env:
IS_PR: ${{ !!github.event.pull_request }}
ONLY_DOCS: ${{ steps.docs-and-hacks.outputs.only_modified }}
run: |
SHOULD_TEST=$(
if [[ $IS_PR == true ]] && [[ $ONLY_DOCS == true ]]; then
echo "false"
else
echo "true"
fi
)

echo "is-pr=$IS_PR" >> "$GITHUB_OUTPUT"
echo "changes_only_docs=${ONLY_DOCS:-false}" >> "$GITHUB_OUTPUT"
echo "should-test=$SHOULD_TEST" >> "$GITHUB_OUTPUT"

- name: Summarize findings
env:
ONLY_DOCS: ${{ steps.docs-and-hacks.outputs.only_modified }}
MODIFIED_FILES: ${{ steps.docs-and-hacks.outputs.all_modified_files }}
run: |
cat >> "$GITHUB_STEP_SUMMARY" <<EOF
## Build container
- CI will run on container: \`${{ steps.grepBuilder.outputs.builder }}\`

## Findings
- The action is PR triggered? \`${{ steps.check-changes.outputs.is-pr }}\`
- Changes are only to docs and hacks? \`${{ steps.check-changes.outputs.changes_only_docs }}\`
- Should the unit test run? \`${{ steps.check-changes.outputs.should-test }}\`
EOF

if [[ $ONLY_DOCS == true ]] && [[ -n "$MODIFIED_FILES" ]]; then
echo "## Modified docs and hacks files that do not impact the build" >> "$GITHUB_STEP_SUMMARY"
for file in ${MODIFIED_FILES}; do
echo " - \`$file\`" >> "$GITHUB_STEP_SUMMARY"
done
fi

unit-test:
runs-on: ubuntu-latest
needs: unit-test-lookup-image
needs: unit-test-lookup
if: ${{ needs.unit-test-lookup.outputs.should-test == 'true' }}

# Use the same container as the Dockerfile's "FROM * as builder"
container: ${{ needs.unit-test-lookup-image.outputs.builder-image }}
container: ${{ needs.unit-test-lookup.outputs.builder-image }}

steps:
- uses: actions/checkout@v4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/image-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ jobs:
image-build:
uses: konveyor/release-tools/.github/workflows/build-push-images.yaml@main
with:
registry: "quay.io/konveyor"
image_name: "tackle2-ui"
registry: ${{ vars.IMAGE_BUILD_REGISTRY || 'quay.io/konveyor' }}
image_name: ${{ vars.IMAGE_BUILD_IMAGE_NAME || 'tackle2-ui' }}
containerfile: "./Dockerfile"

# keep the architectures in sync with `ci-image-build.yml`
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,5 @@ for more information on how to get started.
# Code of Conduct

Refer to Konveyor's [Code of Conduct page](https://github.com/konveyor/community/blob/main/CODE_OF_CONDUCT.md)

This is a change to README.md that should be ignored by CI
31 changes: 31 additions & 0 deletions common/src/proxies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,35 @@ export const proxyMap: Record<string, Options> = {
}
},
},

"/kai": {
target: KONVEYOR_ENV.TACKLE_HUB_URL || "http://localhost:9002",
logLevel: process.env.DEBUG ? "debug" : "info",

changeOrigin: true,
pathRewrite: {
"^/kai": "/services/kai",
},

onProxyReq: (proxyReq, req, _res) => {
// Add the Bearer token to the request if it is not already present, AND if
// the token is part of the request as a cookie
if (req.cookies?.keycloak_cookie && !req.headers["authorization"]) {
proxyReq.setHeader(
"Authorization",
`Bearer ${req.cookies.keycloak_cookie}`
);
}
},
onProxyRes: (proxyRes, req, res) => {
const includesJsonHeaders =
req.headers.accept?.includes("application/json");
if (
(!includesJsonHeaders && proxyRes.statusCode === 401) ||
(!includesJsonHeaders && proxyRes.statusMessage === "Unauthorized")
) {
res.redirect("/");
}
},
},
};
Loading