Skip to content

Commit

Permalink
Merge pull request #486 from wader/test-only-prs
Browse files Browse the repository at this point in the history
Only test PRs, skip master for now
  • Loading branch information
wader authored Oct 8, 2024
2 parents 08bfc73 + 7188051 commit da637cd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,8 @@ jobs:
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
-
name: Build and push branch or test PR
name: Build and test PR
if: github.ref != 'refs/heads/master'
uses: docker/build-push-action@v3
with:
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
target: test
25 changes: 13 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ RUN \
curl -L https://github.com/yt-dlp/yt-dlp/releases/download/$YT_DLP/yt-dlp -o /yt-dlp && \
chmod a+x /yt-dlp

FROM golang:$GOLANG_VERSION AS ydls-base
FROM golang:$GOLANG_VERSION AS base
WORKDIR /src
RUN \
apt-get update -q && \
Expand All @@ -29,15 +29,15 @@ RUN \
COPY --from=ffmpeg /ffmpeg /ffprobe /usr/local/bin/
COPY --from=yt-dlp /yt-dlp /usr/local/bin/

FROM ydls-base AS ydls-dev
FROM base AS dev
ARG TARGETARCH
RUN \
apt-get install --no-install-recommends -qy \
less \
jq \
bsdmainutils

FROM ydls-base AS ydls-builder
FROM base AS builder
COPY go.mod go.sum /src/
COPY cmd /src/cmd
COPY internal /src/internal
Expand All @@ -48,21 +48,22 @@ COPY ydls.json /etc
COPY Dockerfile .git* /src/.git/
RUN (git describe --always 2>/dev/null || echo nogit) > .GIT_COMMIT

# -buildvcs=false for now
# https://github.com/golang/go/issues/51723
# -race only for amd64 for now, should work on arm64 etc but seems to not work in qemu
RUN \
CONFIG=/src/ydls.json \
TEST_EXTERNAL=1 \
go test -timeout=30m -buildvcs=false -v -cover $([ "$TARGETARCH" = "amd64" ] && echo -race) ./...

RUN \
go install \
-buildvcs=false \
-installsuffix netgo \
-tags netgo \
-ldflags "-X main.gitCommit=$(cat .GIT_COMMIT)" \
./cmd/ydls

FROM builder AS test
# -buildvcs=false for now
# https://github.com/golang/go/issues/51723
# -race only for amd64 for now, should work on arm64 etc but seems to not work in qemu
RUN \
CONFIG=/src/ydls.json \
TEST_EXTERNAL=1 \
go test -timeout=30m -buildvcs=false -v -cover $([ "$TARGETARCH" = "amd64" ] && echo -race) ./...
RUN \
CONFIG=/etc/ydls.json cmd/ydls/ydls_server_test.sh && \
CONFIG=/etc/ydls.json cmd/ydls/ydls_get_test.sh
Expand All @@ -80,7 +81,7 @@ RUN apk add --no-cache \
py3-pycryptodome
COPY --from=ffmpeg /ffmpeg /ffprobe /usr/local/bin/
COPY --from=yt-dlp /yt-dlp /usr/local/bin/
COPY --from=ydls-builder /go/bin/ydls /usr/local/bin/
COPY --from=builder /go/bin/ydls /usr/local/bin/
COPY entrypoint.sh /usr/local/bin
COPY ydls.json $CONFIG

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ issues with some sites like youtube.
When fiddling with ffmpeg and yt-dlp related code I usually do this:

```sh
docker build --target ydls-dev -t ydls-dev . && docker run --rm -ti -v "$PWD:/$PWD" -w "$PWD" ydls-dev
docker build --target dev -t ydls-dev . && docker run --rm -ti -v "$PWD:/$PWD" -w "$PWD" ydls-dev
```

Then inside dev container:
Expand Down

0 comments on commit da637cd

Please sign in to comment.