Skip to content

Try to normalize the github workflows #3071

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

Merged
merged 9 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/automerge.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Maybe Enable Auto-Merge
name: Enable Auto-Merge For metacpan-automation
on:
pull_request_target:
types: [opened]
Expand All @@ -9,12 +9,12 @@ jobs:
if: github.event.pull_request.user.login == 'metacpan-automation[bot]'
steps:
- name: Generate Auth Token
id: auth-token
uses: jamestrousdale/github-app-jwt-token@0.1.4
uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- uses: peter-evans/enable-pull-request-automerge@v3
with:
token: ${{ steps.auth-token.outputs.access-token }}
token: ${{ steps.app-token.outputs.token }}
pull-request-number: ${{ github.event.pull_request.number }}
71 changes: 71 additions & 0 deletions .github/workflows/build-container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Build container
on:
push:
branches:
- master
- staging
- prod
pull_request:
branches:
- master
workflow_dispatch:
jobs:
docker:
runs-on: ubuntu-22.04
name: Docker Build and Push
steps:
- name: Generate Auth Token
uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- uses: actions/checkout@v4
with:
token: ${{ steps.app-token.outputs.token }}
- name: Build test image
id: docker-build-test
uses: docker/build-push-action@v5
with:
target: test
push: false
load: true
- name: Run Perl tests
run: docker run -i ${{ steps.docker-build-test.outputs.imageid }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ github.repository }}
flavor: |
latest=false
tags: |
type=sha,format=long,priority=2000
type=ref,event=branch
type=ref,event=pr
type=raw,value=latest,enable={{is_default_branch}}
env:
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index
- name: Build and push
uses: docker/build-push-action@v5
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}
- name: Update deployed image
if: ${{ contains( fromJSON(steps.meta.outputs.json).tags, format('{0}:latest', github.repository)) }}
uses: benc-uk/workflow-dispatch@v1
with:
repo: metacpan/metacpan-k8s
ref: main
workflow: set-image.yml
token: ${{ steps.app-token.outputs.token }}
inputs: '{ "app": "web", "environment": "prod", "base-tag": "${{ github.repository }}:latest", "tag": "${{ fromJSON(steps.meta.outputs.json).tags[0] }}" }'
32 changes: 0 additions & 32 deletions .github/workflows/build-deployment-container.yml

This file was deleted.

47 changes: 0 additions & 47 deletions .github/workflows/build-production-container.yml

This file was deleted.

82 changes: 51 additions & 31 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,60 @@ on:
workflow_dispatch:

jobs:
code-formatting:
runs-on: ubuntu-22.04
name: Code Formatting
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Fetch base ref
if: ${{ github.event.pull_request }}
run: git fetch origin ${{ github.base_ref }}:upstream
- run: npm install
- name: Install Carton
uses: perl-actions/install-with-cpm@v1
with:
install: Carton
- name: Install CPAN deps
uses: perl-actions/install-with-cpm@v1
with:
cpanfile: 'cpanfile'
args: >
--resolver=snapshot
--without-runtime
--without-test
--without-build
--with-develop
- name: Install precious
run: ./bin/install-precious /usr/local/bin
- name: Lint modified files
if: ${{ github.event.pull_request }}
run: precious lint --git-diff-from upstream
- name: Lint all files
if: ${{ ! github.event.pull_request }}
run: precious lint --all
docker:
runs-on: ubuntu-22.04
name: Docker
steps:
- uses: actions/checkout@v4
- name: docker build
run: docker build . --target test -t metacpan/metacpan-web:latest
- name: run Perl tests
run: >
docker run -i metacpan/metacpan-web
carton exec prove -lr --jobs 2 t
- name: Build test image
id: docker-build-test
uses: docker/build-push-action@v5
with:
target: test
push: false
load: true
- name: Run Perl tests
run: docker run -i ${{ steps.docker-build-test.outputs.imageid }}
test:
runs-on: ubuntu-20.04
name: Dockerless
strategy:
fail-fast: false
matrix:
perl-version:
- '5.30'
- '5.36'
resolver:
- snapshot
- metacpan
Expand All @@ -38,14 +73,12 @@ jobs:
DEVEL_COVER_OPTIONS: '-ignore,^local/'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
if: matrix.resolver == 'snapshot'
- uses: actions/checkout@v4
if: matrix.resolver != 'snapshot'
- uses: actions/setup-node@v4
with:
node-version: '18'
node-version: '22'
- run: npm install
- run: apt-get update && apt-get -y install libcmark-dev
- name: Install Carton
Expand All @@ -60,8 +93,6 @@ jobs:
sudo: false
args: >
--resolver ${{ matrix.resolver }}
--show-build-log-on-failure
--local-lib-contained=local
- name: Build assets
run: npm run build
- name: Run tests without coverage
Expand All @@ -75,30 +106,19 @@ jobs:
with:
install: |
Devel::Cover
Devel::Cover::Report::Codecov
Devel::Cover::Report::Codecovbash
sudo: false
- name: Run tests with coverage
if: matrix.resolver == 'snapshot'
run: carton exec prove -lr --jobs 2 t
env:
HARNESS_PERL_SWITCHES: -MDevel::Cover=+ignore,^t/
- name: Upload coverage reports to Codecov
- name: Generate Codecov report
if: matrix.resolver == 'snapshot'
run: cover -report codecov
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Install precious
run: ./bin/install-precious /usr/local/bin
- name: Install perlimports
run: cpm install -g App::perlimports
run: cover -report codecovbash
- uses: codecov/codecov-action@v4
if: matrix.resolver == 'snapshot'
- name: Fetch master
run: git fetch origin master:master
if: github.ref != 'refs/heads/master' && matrix.resolver == 'snapshot'
- name: Lint files in diff (branch)
run: precious lint -d master
if: github.ref != 'refs/heads/master' && matrix.resolver == 'snapshot'
- name: Lint all files (master)
run: precious lint --all
if: github.ref == 'refs/heads/master' && matrix.resolver == 'snapshot'
with:
fail_ci_if_error: true
file: ./cover_db/codecov.json
token: ${{ secrets.CODECOV_TOKEN }}
11 changes: 6 additions & 5 deletions .github/workflows/update-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ jobs:
runs-on: 'ubuntu-20.04'
steps:
- name: Generate Auth Token
id: auth-token
uses: jamestrousdale/github-app-jwt-token@0.1.4
uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- id: git-user
name: Set up git user
uses: haarg/setup-git-user@v1
with:
jwt: ${{ steps.auth-token.outputs.jwt }}
app: ${{ steps.app-token.outputs.app-slug }}
- uses: actions/checkout@v4
with:
token: ${{ steps.auth-token.outputs.access-token }}
token: ${{ steps.app-token.outputs.token }}
- name: Set up installation local::lib
run: |
mkdir -p $RUNNER_TEMP/perl5/bin
Expand Down Expand Up @@ -64,12 +64,13 @@ jobs:
--resolver metacpan
--show-build-log-on-failure
--local-lib-contained=local
--with-develop
- name: Maybe update cpanfile.snapshot
run: carton
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
token: ${{ steps.auth-token.outputs.access-token }}
token: ${{ steps.app-token.outputs.token }}
commit-message: Update cpanfile.snapshot
title: Update cpanfile.snapshot
author: ${{ steps.git-user.outputs.user-full }}
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ RUN \
apt-get satisfy -y -f --no-install-recommends 'libcmark-dev (>= 0.30.2)'
EOT

WORKDIR /metacpan-web/
WORKDIR /app/

COPY cpanfile cpanfile.snapshot ./
RUN \
Expand All @@ -47,8 +47,8 @@ EOT

RUN mkdir var && chown metacpan:users var

ENV PERL5LIB="/metacpan-web/local/lib/perl5"
ENV PATH="/metacpan-web/local/bin:${PATH}"
ENV PERL5LIB="/app/local/lib/perl5"
ENV PATH="/app/local/bin:${PATH}"

COPY *.md app.psgi *.conf ./
COPY bin bin
Expand Down
8 changes: 4 additions & 4 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
comment:
layout: 'diff, files'
behavior: default
require_changes: true # if true: only post the comment if coverage changes
require_base: false # [true :: must have a base report to post]
require_head: true # [true :: must have a head report to post]
hide_project_coverage: false # [true :: only show coverage on the git diff]
require_changes: true # if true: only post the comment if coverage changes
require_base: false # [true :: must have a base report to post]
require_head: true # [true :: must have a head report to post]
hide_project_coverage: false # [true :: only show coverage on the git diff]
coverage:
status:
patch:
Expand Down
Loading