feat: Remove magic strings from Source type #256
Workflow file for this run
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
name: ci | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
on: | |
pull_request: | |
branches: | |
- main | |
paths: | |
- "*.go" | |
- "**/*.go" | |
- Dockerfile | |
- docker-bake.hcl | |
- .github/workflows/ci.yml | |
- frontend/mariner2/Dockerfile | |
- go.mod | |
- go.sum | |
push: | |
branches: | |
- main | |
paths: | |
- "*.go" | |
- "**/*.go" | |
- Dockerfile | |
- docker-bake.hcl | |
- .github/workflows/ci.yml | |
- frontend/mariner2/Dockerfile | |
- go.mod | |
- go.sum | |
permissions: | |
contents: read | |
jobs: | |
lint: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: checkout | |
uses: actions/checkout@v3 | |
- uses: actions/setup-go@v4 | |
with: | |
go-version: '1.21' | |
cache: false | |
# Use the golang-ci lint action which automattically sets up GHA caching and other things | |
# Note: There is also a "lint" target in docker-bake.hcl for local linting | |
# If you make changes to this, please make sure to also update the local linting target | |
- name: golangci-lint | |
uses: golangci/golangci-lint-action@v3 | |
with: | |
version: v1.54 | |
args: --timeout=30m | |
- name: validate generated files | |
run: | | |
go generate || exit $? | |
git diff --exit-code | |
if [ $? -ne 0 ]; then | |
echo "::error::Missing updates to generated files. Please run 'go generate' and commit the changes" | |
exit 1 | |
fi | |
integration: | |
runs-on: ubuntu-22.04 | |
# TODO: support diff/merge | |
# Right now this is handled by the e2e suite, but we can migrate that here. | |
steps: | |
- name: checkout | |
uses: actions/checkout@v3 | |
- uses: actions/setup-go@v4 | |
with: | |
go-version: '1.21' | |
cache: false | |
- name: Run integration tests | |
run: go test -v ./test | |
unit: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: checkout | |
uses: actions/checkout@v3 | |
- uses: actions/setup-go@v4 | |
with: | |
go-version: '1.21' | |
cache: false | |
- name: Run unit tests | |
run: go test -v . | |
e2e: | |
runs-on: ubuntu-22.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
disable_diff_merge: ["1", "0"] | |
name: "Test E2E (disable diff/merge: ${{ matrix.disable_diff_merge }})" | |
env: | |
DALEC_DISABLE_DIFF_MERGE: ${{ matrix.disable_diff_merge }} | |
FRONTEND_REF: localhost:5000/dalec/frontend | |
steps: | |
- name: checkout | |
uses: actions/checkout@v3 | |
with: | |
# We need to fetch all commits so that we can diff against the base branch | |
fetch-depth: 0 | |
- name: Expose GitHub tokens for caching | |
uses: crazy-max/ghaction-github-runtime@v3 | |
- name: Setup builder | |
run: | | |
# Sometimes the builder runs out of space... so cleanup anything we can first. | |
docker image prune -a -f | |
docker run -d --net=host registry | |
# If diff/merge are enabled we need to use a buildx builder to make sure the feature is supported. | |
# Otherwise we can just use the default docker builder. | |
if [ "${DALEC_DISABLE_DIFF_MERGE}" = "0" ]; then | |
docker buildx create --use --driver-opt network=host | |
echo FRONTEND_BAKE_TARGET="frontend-ci-full" >> $GITHUB_ENV | |
echo USE_BUILDX=1 >> $GITHUB_ENV | |
else | |
echo DALEC_NO_CACHE_EXPORT="1" >> $GITHUB_ENV | |
echo DALEC_DISABLE_NESTED="1" >> $GITHUB_ENV | |
echo FRONTEND_BAKE_TARGET="frontend-ci" >> $GITHUB_ENV | |
fi | |
# Check if the mariner2 toolchain was modified and needs to be rebuilt | |
# The bake file will take care of rebuilding it if needed | |
set -e | |
diff="$(git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} HEAD)" | |
set +e | |
grep frontend/mariner2/Dockerfile <<<"${diff}" && \ | |
echo REBUILD_MARINER2_TOOLCHAIN=1 >> $GITHUB_ENV | |
echo "MARINER2_TOOLCHAIN_CACHE_REF=$(tr '[:upper:]' '[:lower:]' <<< "ghcr.io/${{ github.repository }}/mariner2/toolchain:cache")" >> $GITHUB_ENV | |
- name: Build frontend image | |
run: docker buildx bake ${FRONTEND_BAKE_TARGET} | |
- name: test | |
run: | | |
docker buildx bake \ | |
--set mariner2-toolchain.cache-from=type=registry,ref=${MARINER2_TOOLCHAIN_CACHE_REF} \ | |
test | |
- name: dump logs | |
if: failure() | |
run: | | |
if [ "${USE_BUILDX}" = "1" ]; then | |
docker logs $(docker ps -lq) | |
else | |
sudo journalctl -u docker | |
fi |