diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml new file mode 100644 index 0000000..cc352f0 --- /dev/null +++ b/.github/workflows/dev.yml @@ -0,0 +1,35 @@ +name: 'Build and Test' + +on: pull_request + +jobs: + build_and_test: + name: Build and Test + runs-on: ubuntu-latest + steps: + - name: Checkout the repository + uses: actions/checkout@v2 + + - name: Generate an SSL certificate for testing (silently) + run: openssl req -new -newkey rsa:1024 -days 365 -nodes -x509 -subj "/C=US/ST=NC" -keyout test/certs/test.key -out test/certs/test.cert + + - name: Build + run: docker build -t robokache . + + - name: Test & Get Coverage + run: docker run --name robokache_runner robokache sh -c "go test ./internal/robokache -coverprofile=cover.out" + + - name: Copy coverage report from container + run: docker cp robokache_runner:/app/cover.out cover.out + + - name: Convert coverage to lcov + uses: jandelgado/gcov2lcov-action@v1.0.0 + with: + infile: cover.out + outfile: cover.lcov + + - name: Report coverage as comment in pull request + uses: romeovs/lcov-reporter-action@v0.2.16 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + lcov-file: ./cover.lcov diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..1800816 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,25 @@ +name: 'Push to Github Packages' + +on: + pull_request: + types: closed + branches: + - main + +jobs: + push_to_registry: + name: Push Docker image to GitHub Packages tagged with commit hash. + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v2 + - name: Push to GitHub Packages + uses: docker/build-push-action@v1 + with: + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + registry: docker.pkg.github.com + # Uppercase letters are not supported so this is all lowercase + repository: ncats-gamma/robokache/build + tag_with_sha: true + tags: main diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..8d9d6b1 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,23 @@ +name: 'Release a new version to Github Packages' + +on: release + +jobs: + push_to_registry: + name: Push Docker image to GitHub Packages tagged with "latest" and version number. + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v2 + - name: Get the version + id: get_version + run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} + - name: Push to GitHub Packages + uses: docker/build-push-action@v1 + with: + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + registry: docker.pkg.github.com + # Uppercase letters are not supported so this is all lowercase + repository: ncats-gamma/robokache/build + tags: latest,${{ steps.get_version.outputs.VERSION }}