Skip to content
Snippets Groups Projects
.gitlab-ci.yml 3.76 KiB
Newer Older
  • Learn to ignore specific revisions
  • image: code.castopod.org:5050/adaures/castopod:ci-php8.3
    
      stage: prepare
      script:
        # Install all php dependencies
        - composer install --prefer-dist --no-ansi --no-interaction --no-progress --ignore-platform-reqs
    
      cache:
        key:
          files:
            - composer.lock
        paths:
          - .composer-cache
    
        paths:
          - vendor/
    
    js-dependencies:
      stage: prepare
      script:
    
        # Install all js dependencies
        - pnpm install
      cache:
        key:
          files:
            - pnpm-lock.yaml
        paths:
          - .pnpm-store
    
        - chmod +x ./scripts/lint-commit-msg.sh
    
        - ./scripts/lint-commit-msg.sh
    
        # phpstan - increase memory limit to 1GB to prevent script failure
    
        - php -d memory_limit=1G vendor/bin/phpstan analyse --ansi
    
        - vendor/bin/rector process --dry-run --ansi
    
        - pnpm run prettier
        - pnpm run typecheck
        - pnpm run lint
        - pnpm run lint:css
    
      variables:
        MYSQL_ROOT_PASSWORD: "R00Tp4ssW0RD"
    
        MYSQL_DATABASE: "test"
        MYSQL_USER: "castopod"
        MYSQL_PASSWORD: "castopod"
    
        - echo "SHOW DATABASES;" | mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host=mariadb "$MYSQL_DATABASE"
    
    
        # run phpunit without code coverage
        # TODO: add code coverage
        - vendor/bin/phpunit --no-coverage
    
      before_script:
        # prepare dependencies before bundling
        - chmod +x ./scripts/bundle-prepare.sh
        - ./scripts/bundle-prepare.sh
    
        # make scripts/bundle.sh executable
        - chmod +x ./scripts/bundle.sh
    
        # bundle castopod with commit ref as version
    
        - ./scripts/bundle.sh ${CI_COMMIT_REF_SLUG}_${CI_COMMIT_SHORT_SHA}
    
      dependencies:
        - php-dependencies
        - js-dependencies
    
        name: "castopod-${CI_COMMIT_REF_SLUG}_${CI_COMMIT_SHORT_SHA}"
    
      only:
        variables:
          - $CI_PROJECT_NAMESPACE == "adaures"
    
      before_script:
        # IMPORTANT: delete local git tags before release to prevent eventual script failure (ie. tag already exists)
        - git tag | xargs git tag -d
    
        # prepare dependencies before release, both bundle and package scripts will be run by semantic-release
        - chmod +x ./scripts/bundle-prepare.sh
        - ./scripts/bundle-prepare.sh
    
        # make release scripts executable
        - chmod +x ./scripts/bundle.sh
        - chmod +x ./scripts/package.sh
    
    
        # run semantic-release script (configured in `.releaserc.json` file)
    
      dependencies:
        - php-dependencies
        - js-dependencies
    
    website:
      stage: deploy
      trigger: adaures/castopod.org
      only:
        - main
        - beta
        - alpha
    
    
    documentation:
      stage: deploy
      trigger:
        include: docs/.gitlab-ci.yml
        strategy: depend
    
    
    docker:
      stage: build
      trigger:
        include: docker/production/.gitlab-ci.yml
        strategy: depend
      variables:
        PARENT_PIPELINE_ID: $CI_PIPELINE_ID
    
      only:
        refs:
          - develop
          - main
          - beta
          - alpha
        variables:
          - $CI_PROJECT_NAMESPACE == "adaures"