Commit e33c06ad authored by Federico Falconieri's avatar Federico Falconieri
Browse files

Merge branch 'beta' into 'main'

feat!: improves container pipelines, kaniko and grype in monorepo and polirepo repositories

Closes #19, #12, #16, #25, #27, and #28

See merge request just-ci/templates!53
parents c52e1600 26bd9df1
Loading
Loading
Loading
Loading
+15 −20
Original line number Diff line number Diff line
@@ -15,18 +15,6 @@ gitlab:recommended:
  variables:
    GITLAB_RECOMMENDED_AUTO_FIX: "true"

badge:test:
  extends: .badge
  stage: test
  variables:
    NAME: "branch"
    VALUE: "${CI_COMMIT_REF_NAME}"
    COLOR: "fuchsia"
  rules:
    - if: $GL_TOKEN
      when: never
    - when: always

pages:
  stage: test
  before_script:
@@ -45,11 +33,11 @@ jobs:c:
      - local: tests/jobs/c.yml
    strategy: depend

jobs:docker:
jobs:container:
  stage: test
  trigger:
    include:
      - local: tests/jobs/docker.yml
      - local: tests/jobs/container.yml
    strategy: depend

jobs:docs:
@@ -74,23 +62,30 @@ pipelines:c:
      - local: tests/pipelines/c.yml
    strategy: depend

pipelines:docker:
pipelines:python:
  stage: test
  trigger:
    include:
      - local: tests/pipelines/docker.yml
      - local: tests/pipelines/python.yml
    strategy: depend

pipelines:python:
pipelines:container:polyrepo:
  stage: test
  trigger:
    include:
      - local: tests/pipelines/python.yml
      - local: tests/pipelines/container/polyrepo.yml
    strategy: depend

pipelines:container:monorepo:
  stage: test
  trigger:
    include:
      - local: tests/pipelines/container/monorepo.yml
    strategy: depend

pipelines:python&docker:
pipelines:container:python:
  stage: test
  trigger:
    include:
      - local: tests/pipelines/python-docker.yml
      - local: tests/pipelines/container/python.yml
    strategy: depend
+14 −25
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ include:

The above is a template for Python projects. Other templates can be found in `templates/`, for example:

* Python projects with a `Dockerfile`: `templates/python-docker.yml`. This template will use your `Dockerfile` to create an image in which we run tests.
* Python projects with a `Dockerfile`: `templates/container/python.yml`. This template will use your `Dockerfile` to create an image in which we run tests.
* C projects: `templates/c.yml`.

## Disabling specific jobs
@@ -81,46 +81,35 @@ include:
    ref: 'v3.19.2'
```

# Repositories with multiple `Dockerfile`s
# monorepos vs polirepos

Use [child pipelines](https://docs.gitlab.com/ee/ci/pipelines/parent_child_pipelines.html) to work with multiple dockerfiles. An example is provided, based on a mockup project used within the tests of this repository.
We support both! Read [this](pipelines/container/readme.md) for more information on how to configure pipelines for monorepos and polirepos.

> `.gitlab-ci.yml`
### example python polyrepo

Polirepos will likely work out of the box without extra configuration needed.

```yaml
---
include:
  - project: 'just-ci/templates'
    templates: 'templates/docker.yml'
    ref: 'v4.1.2'
    # root image will build fine without any further change needed

# child pipeline for second docker image
second-image:
  stage: build
  inherit:
    variables: false
  trigger:
    include:
      - local: second-image/.gitlab-ci.yml
    strategy: depend
    file: 'templates/container/python.yml'
    ref: v5.0.0-beta.1
```

> `second-image/.gitlab-ci.yml`
### example monorepo

In monorepos you can start by including the following, but you will need to write your own kaniko and grype job. Again, read [this](pipelines/container/readme.md)

```yaml
---
include:
  - project: 'just-ci/templates'
    file: 'templates/docker.yml'
    ref: 'v4.1.2'

variables:
  KANIKO_REGISTRY_IMAGE: ${CI_REGISTRY_IMAGE}/second-image
  KANIKO_CONTEXT: ${CI_PROJECT_DIR}/second-image
  KANIKO_DOCKERFILE: ${CI_PROJECT_DIR}/second-image/Dockerfile
    file: 'templates/container/monorepo.yml'
    ref: v5.0.0-beta.1
```


## Contributing

See [`CONTRIBUTING.md`](CONTRIBUTING.md)

cd/ssh/clone.yml

0 → 100644
+11 −0
Original line number Diff line number Diff line
---
clone:
  extends: .ssh
  GIT_SUBMODULE_STRATEGY: recursive
  script:
    - ssh ${REMOTE_USER}@${REMOTE_HOST} "
        git config --global user.email 'bot@mail.com' &&
        git config --global user.name 'bot' &&
        rm -rf ${CI_PROJECT_NAME} &&
        git clone --recurse-submodules --branch ${CI_COMMIT_REF_NAME} --depth 1 https://${DEPLOY_USER}:${DEPLOY_TOKEN}@${CI_SERVER_HOST}/gitlab/${CI_PROJECT_PATH} &&
        exit"
+5 −0
Original line number Diff line number Diff line
---
docker:login:
  extends: .ssh
  script:
    - ssh ${REMOTE_USER}@${REMOTE_HOST} -p ${REMOTE_PORT:=22} "docker login ${CI_REGISTRY} -u ${DEPLOY_USER} -p ${DEPLOY_TOKEN}"

cd/ssh/make.yml

0 → 100644
+10 −0
Original line number Diff line number Diff line
---
variables:
    DEPLOY_MAKE_TARGET: $CI_PROJECT_NAME
    DEPLOY_MAKE_EXTRA_ARGS: ""
    DEPLOY_MAKE_ENV_VARIABLES: ""

deploy:make:
    extends: .ssh
    script:
        - ssh ${REMOTE_USER}@${REMOTE_HOST} "cd ${CI_PROJECT_NAME} && ${DEPLOY_MAKE_ENV_VARIABLES} make ${DEPLOY_MAKE_EXTRA_ARGS} ${CI_PROJECT_NAME} && exit"
Loading