diff --git a/.github/workflows/release.yml b/.github/workflows/Merge.yml similarity index 58% rename from .github/workflows/release.yml rename to .github/workflows/Merge.yml index bce0c5855..a8b49d3ad 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/Merge.yml @@ -1,21 +1,22 @@ -name: Release +name: Merge on: - release: - types: [prereleased] + push: + branches: + - master jobs: + vet: + uses: ./.github/workflows/vet.yml + unit-test: + uses: ./.github/workflows/unit.yml build: uses: ./.github/workflows/build.yml e2e: + if: ${{ always() && contains(join(needs.*.result, ','), 'success') }} + needs: [build, vet, unit-test] uses: ./.github/workflows/e2e.yml integration: - uses: ./.github/workflows/integration.yml - publish: if: ${{ always() && contains(join(needs.*.result, ','), 'success') }} - needs: [build, e2e, integration] - uses: ./.github/workflows/publish.yml - docs: - if: ${{ always() && contains(join(needs.*.result, ','), 'success') }} - needs: [build, e2e, integration] - uses: ./.github/workflows/docs.yml + needs: [build, vet, unit-test] + uses: ./.github/workflows/integration.yml diff --git a/.github/workflows/PR.yml b/.github/workflows/PR.yml new file mode 100644 index 000000000..d4c5905e5 --- /dev/null +++ b/.github/workflows/PR.yml @@ -0,0 +1,25 @@ +name: PR + +on: + pull_request: + types: ['opened', 'reopened', 'synchronize'] + branches: [ "master" ] + paths: + - '**' # all files otherwise excludes wont work + - '!**/**/*.md' # ignore markdown files + +jobs: + vet: + uses: ./.github/workflows/vet.yml + unit-test: + uses: ./.github/workflows/unit.yml + build: + uses: ./.github/workflows/build.yml + e2e: + if: ${{ always() && contains(join(needs.*.result, ','), 'success') }} + needs: [build, vet, unit-test] + uses: ./.github/workflows/e2e.yml + integration: + if: ${{ always() && contains(join(needs.*.result, ','), 'success') }} + needs: [build, vet, unit-test] + uses: ./.github/workflows/integration.yml diff --git a/.github/workflows/README.md b/.github/workflows/README.md new file mode 100644 index 000000000..ded212405 --- /dev/null +++ b/.github/workflows/README.md @@ -0,0 +1,15 @@ +# Workflows + +There are two types of workflows in this directory. I would put them in subfolders but GitHub Actioins don't support that. Since we can't use folders, capital letters are used for the "Caller" workflows and lowercase for the "Job" workflows. This is just a convention to help keep track of what is what. + +## Callers + +These are the high level workflows that can be associated with what triggers them. PRs, releases, nightlys, merges, etc. These are made up of jobs that are defined the the other workflows. These are the workflows that you will see in the Actions tab of the repo. By grouping these tasks into parent workflows, the jobs are grouped under one action in the actions tab. They share the smaller 'job' workflows so that they always run the same way. + +## Jobs + +These are the smaller individual tasks that are used to build up the larger parent workflows. They can be thought of as running unit tests, building the binaries, or linting the code. When you open one of the parent caller actions in the actions tab, they will show these individual jobs. + +# Working with workflows + +The easiest way to test a workflow is by creating it on your forked repo. This way you have control over the settings and you can manipulate branches anyway you need to trigger the workflow. When testing this way, you should be careful that you are pushing to your repo and not the company's and also make sure to clean everything up in your repo once you have finished testing. diff --git a/.github/workflows/Release.yml b/.github/workflows/Release.yml new file mode 100644 index 000000000..00a0b4b3e --- /dev/null +++ b/.github/workflows/Release.yml @@ -0,0 +1,29 @@ +name: Release + +on: + release: + types: [prereleased] + +jobs: + vet: + uses: ./.github/workflows/vet.yml + unit-test: + uses: ./.github/workflows/unit.yml + build: + uses: ./.github/workflows/build.yml + e2e: + if: ${{ always() && contains(join(needs.*.result, ','), 'success') }} + needs: [build, vet, unit-test] + uses: ./.github/workflows/e2e.yml + integration: + if: ${{ always() && contains(join(needs.*.result, ','), 'success') }} + needs: [build, vet, unit-test] + uses: ./.github/workflows/integration.yml + publish: + if: ${{ always() && contains(join(needs.*.result, ','), 'success') }} + needs: [build, e2e, integration, unit-test, vet] + uses: ./.github/workflows/publish.yml + docs: + if: ${{ always() && contains(join(needs.*.result, ','), 'success') }} + needs: [build, e2e, integration, unit-test, vet] + uses: ./.github/workflows/docs.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ee0787b20..3c6520b8d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,13 +1,8 @@ name: Build on: - push: - branches: [ "master" ] - pull_request: - branches: [ "master" ] workflow_call: - jobs: linux: runs-on: ubuntu-latest diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index d96074095..b847e1d61 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -1,10 +1,6 @@ name: End-to-End Tests on: - push: - branches: [ master ] - pull_request: - branches: [ master ] workflow_call: jobs: diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 622a6f434..3c8e5ee17 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -1,10 +1,6 @@ name: Integration Tests on: - push: - branches: [ master ] - pull_request: - branches: [ master ] workflow_call: jobs: diff --git a/.github/workflows/unit.yml b/.github/workflows/unit.yml new file mode 100644 index 000000000..50596d017 --- /dev/null +++ b/.github/workflows/unit.yml @@ -0,0 +1,25 @@ +name: Run Unit Tests + +on: + workflow_call: + +jobs: + unit-tests: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Load environment + uses: c-py/action-dotenv-to-setenv@v4 + with: + env-file: .github/.env + + - name: Setup Go ${{ env.GO_VERSION }} + uses: actions/setup-go@v4 + with: + go-version: ${{ env.GO_VERSION }} + + - name: Run Unit Tests + working-directory: . + run: make test diff --git a/.github/workflows/vet.yml b/.github/workflows/vet.yml new file mode 100644 index 000000000..fb7a97b88 --- /dev/null +++ b/.github/workflows/vet.yml @@ -0,0 +1,25 @@ +name: Vet Go Code + +on: + workflow_call: + +jobs: + vet: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Load environment + uses: c-py/action-dotenv-to-setenv@v4 + with: + env-file: .github/.env + + - name: Setup Go ${{ env.GO_VERSION }} + uses: actions/setup-go@v4 + with: + go-version: ${{ env.GO_VERSION }} + + - name: Vet Go Code + working-directory: . + run: go vet diff --git a/README.md b/README.md index e2ccd463d..db033d496 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ -![docker and kubernetes interact](docs/static/images/logo.svg) +

+ docker and kubernetes interact +

# cri-dockerd @@ -6,6 +8,8 @@ This adapter provides a shim for [Docker Engine](https://docs.docker.com/engine/ that lets you control Docker via the Kubernetes [Container Runtime Interface](https://github.com/kubernetes/cri-api#readme). +Take a look at the [official docs](https://mirantis.github.io/cri-dockerd/) for more information. + ## IMPORTANT For users running `0.2.5` or above, the default network plugin is `cni`. Kubernetes 1.24+ has removed `kubenet` and diff --git a/docs/content/development/unit-tests.md b/docs/content/development/unit-tests.md new file mode 100644 index 000000000..0fabe028e --- /dev/null +++ b/docs/content/development/unit-tests.md @@ -0,0 +1,16 @@ +--- +weight: 2 +--- + +Unit tests can be ran on your local machine without the need for minikube. + +## Run the tests + +Open a terminal and run the following command: + +``` bash +make test +``` + +The tests will run and the results will be printed to the terminal with a summary +at the end of the test run.