-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
ci: Fix CI for forks #16776
Merged
Merged
ci: Fix CI for forks #16776
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
0372c05
ci: Fix CI for forks
Twixes 4169e71
Try updating snapshots on forks
Twixes d23b79a
Try fixing snapshot verification instead
Twixes aaf044e
Consolidate Docker-related workflows
Twixes dd877d7
Run visual regression tests
Twixes e12f78f
Update ci-e2e.yml
Twixes 9cc8fa5
Use fork's GHCR
Twixes 4a3eea9
Try Depot caching approach instead of GHCR
Twixes 84c068b
Lowercase reference
Twixes 350a5d1
Update E2E tests paths filter
Twixes 04f0399
Fix permissions
Twixes 4ff509c
Debug .env
Twixes 4770e32
Fix double checkout
Twixes d208ca1
Remove obsolete release workflows
Twixes c8ab9c5
Fix formatting
Twixes d97c250
Also run plugin server tests for good measure
Twixes 26a5584
Clarify automerge job name
Twixes 623fc74
Describe action inputs
Twixes be04a52
Refactor E2E workflow for clarity and comments
Twixes 06d1863
Use project ID from depot.json
Twixes 1aff6d8
Merge branch 'master' into new-color
Twixes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: Build and cache Docker image | ||
|
||
inputs: | ||
actions-id-token-request-url: | ||
required: true | ||
description: "ACTIONS_ID_TOKEN_REQUEST_URL, issued by GitHub when permission 'id-token' is set to 'write'" | ||
load: | ||
required: false | ||
default: 'false' | ||
description: Whether to load the image into local Docker after building it | ||
|
||
outputs: | ||
tag: | ||
description: The tag of the image that was built | ||
value: ${{ steps.emit.outputs.tag }} | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Set up Depot CLI | ||
uses: depot/setup-action@v1 | ||
|
||
- name: Emit image tag | ||
id: emit | ||
shell: bash | ||
run: echo "tag=posthog/posthog:${{ github.sha }}" >> $GITHUB_OUTPUT | ||
|
||
- name: Build image # We don't push this because we use Depot cache as the communication channel | ||
id: build | ||
uses: depot/build-push-action@v1 | ||
with: | ||
buildx-fallback: false # buildx is so slow it's better to just fail | ||
load: ${{ inputs.load }} | ||
tags: ${{ steps.emit.outputs.tag }} | ||
platforms: linux/amd64,linux/arm64 | ||
env: | ||
ACTIONS_ID_TOKEN_REQUEST_URL: ${{ inputs.actions-id-token-request-url }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,66 +32,56 @@ jobs: | |
# NOTE: we are at risk of missing a dependency here. We could make | ||
# the dependencies more clear if we separated the backend/frontend | ||
# code completely | ||
- 'ee/**/*' | ||
- 'posthog/**/*' | ||
- 'hogvm/**/*' | ||
- 'bin/*.py' | ||
- 'ee/**' | ||
- 'posthog/**' | ||
- 'hogvm/**' | ||
- 'bin/*' | ||
- frontend/**/* | ||
- requirements.txt | ||
- requirements-dev.txt | ||
- mypy.ini | ||
- pytest.ini | ||
- package.json | ||
- pnpm-lock.yaml | ||
# Make sure we run if someone is explicitly change the workflow | ||
- .github/workflows/ci-e2e.yml | ||
- .github/actions/build-n-cache-inage/action.yml | ||
# We use docker compose for tests, make sure we rerun on | ||
# changes to docker-compose.dev.yml e.g. dependency | ||
# version changes | ||
- docker-compose.dev.yml | ||
- frontend/**/* | ||
- Dockerfile | ||
|
||
# Job that lists and chunks spec file names and caches node modules | ||
cypress_prep: | ||
chunks: | ||
needs: changes | ||
name: Cypress preparation | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 30 | ||
outputs: | ||
specs: ${{ steps.set-specs.outputs.specs }} | ||
chunks: ${{ steps.chunk.outputs.chunks }} | ||
|
||
steps: | ||
- name: Wait for the container image to be ready | ||
# these are required checks so, we can't skip entire sections | ||
if: needs.changes.outputs.shouldTriggerCypress == 'true' | ||
uses: lewagon/[email protected] | ||
with: | ||
check-name: Build PostHog | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
wait-interval: 10 | ||
|
||
- name: Checkout code | ||
- name: Check out | ||
uses: actions/checkout@v3 | ||
|
||
- name: List cypress/e2e and produce a JSON array of the files, in chunks | ||
id: set-specs | ||
run: echo "specs=$(ls cypress/e2e/* | jq --slurp --raw-input -c 'split("\n")[:-1] | _nwise(3) | join("\n")' | jq --slurp -c .)" >> $GITHUB_OUTPUT | ||
- name: Group spec files into chunks of three | ||
id: chunk | ||
run: echo "chunks=$(ls cypress/e2e/* | jq --slurp --raw-input -c 'split("\n")[:-1] | _nwise(3) | join("\n")' | jq --slurp -c .)" >> $GITHUB_OUTPUT | ||
|
||
cypress: | ||
name: Cypress E2E tests (${{ strategy.job-index }}) | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 30 | ||
needs: [cypress_prep, changes] | ||
needs: [chunks, changes] | ||
permissions: | ||
packages: read # allow pull from ghcr.io | ||
id-token: write # allow issuing OIDC tokens for this workflow run | ||
|
||
strategy: | ||
# when one test fails, DO NOT cancel the other | ||
# containers, as there may be other spec failures | ||
# we want to know about. | ||
fail-fast: false | ||
matrix: | ||
specs: ${{ fromJson(needs.cypress_prep.outputs.specs) }} | ||
chunk: ${{ fromJson(needs.chunks.outputs.chunks) }} | ||
|
||
steps: | ||
- name: Checkout | ||
|
@@ -147,7 +137,18 @@ jobs: | |
if: needs.changes.outputs.shouldTriggerCypress == 'true' | ||
run: ./bin/check_kafka_clickhouse_up | ||
|
||
- name: Setup env | ||
- name: Get Docker image cached in Depot | ||
# We don't actually build the image here, because we use Depot, which acts as our cross-workflow cache. | ||
# The build is first initiated in container-images-ci.yml, so by the time this runs, some layers already | ||
# are cached, and the in-flight builds overall are deduplicated. According to Depot folks, this applies | ||
# even if the builds _start_ concurrently! In short, only one build per commit push is ever executed. | ||
uses: ./.github/actions/build-n-cache-image | ||
id: docker-build | ||
with: | ||
actions-id-token-request-url: ${{ env.ACTIONS_ID_TOKEN_REQUEST_URL }} | ||
load: true | ||
|
||
- name: Write .env | ||
run: | | ||
cat <<EOT >> .env | ||
SECRET_KEY=6b01eee4f945ca25045b5aab440b953461faf08693a9abbf1166dc7c6b9772da | ||
|
@@ -171,26 +172,14 @@ jobs: | |
GITHUB_ACTION_RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | ||
EOT | ||
|
||
- name: Lowercase GITHUB_REPOSITORY | ||
id: lowercase | ||
run: | | ||
echo "repository=${GITHUB_REPOSITORY,,}" >> "$GITHUB_OUTPUT" | ||
|
||
- name: Get the PostHog container image of this PR | ||
if: needs.changes.outputs.shouldTriggerCypress == 'true' | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: ghcr.io/${{ steps.lowercase.outputs.repository }}/posthog | ||
|
||
- name: Start PostHog | ||
# these are required checks so, we can't skip entire sections | ||
if: needs.changes.outputs.shouldTriggerCypress == 'true' | ||
run: | | ||
mkdir -p /tmp/logs | ||
|
||
echo "Starting PostHog using the container image ${{ steps.meta.outputs.tags }}" | ||
DOCKER_RUN="docker run --rm --network host --add-host kafka:127.0.0.1 --env-file .env ${{ steps.meta.outputs.tags }}" | ||
echo "Starting PostHog using the container image ${{ steps.docker-build.outputs.tag }}" | ||
DOCKER_RUN="docker run --rm --network host --add-host kafka:127.0.0.1 --env-file .env ${{ steps.docker-build.outputs.tag }}" | ||
|
||
$DOCKER_RUN ./bin/migrate | ||
$DOCKER_RUN python manage.py setup_dev | ||
|
@@ -216,7 +205,7 @@ jobs: | |
with: | ||
config-file: cypress.e2e.config.ts | ||
config: retries=2 | ||
spec: ${{ matrix.specs }} | ||
spec: ${{ matrix.chunk }} | ||
install: false | ||
|
||
- name: Archive test screenshots | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Action inputs don't actually have a
type
parameter (they're all strings for GitHub)