---
kind: pipeline
type: docker
name: build-amd64

platform:
  os: linux
  arch: amd64

workspace:
  base: /go
  path: src/srs.epita.fr/fic-server

steps:
  - name: get deps
    image: golang:alpine
    commands:
      - apk --no-cache add git
      - go get -v -d ./...
      - mkdir deploy

  - name: build qa ui
    image: node:22-alpine
    commands:
      - cd qa/ui
      - npm install --network-timeout=100000
      - npm run build
      - tar chjf ../../deploy/htdocs-qa.tar.bz2 build

  - name: vet and tests
    image: golang:alpine
    commands:
      - apk --no-cache add build-base
      - go vet -buildvcs=false -tags gitgo ./...
      - go vet -buildvcs=false ./...
      - go test ./...

  - name: build admin
    image: golang:alpine
    commands:
      - go build -buildvcs=false -tags gitgo -o deploy/admin-gitgo-${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH} srs.epita.fr/fic-server/admin
      - go build -buildvcs=false -o deploy/admin-${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH} srs.epita.fr/fic-server/admin
      - tar chjf deploy/htdocs-admin.tar.bz2 htdocs-admin
    environment:
      CGO_ENABLED: 0
    when:
      branch:
        exclude:
          - master

  - name: build checker
    image: golang:alpine
    commands:
      - go build -buildvcs=false -o deploy/checker-${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH} srs.epita.fr/fic-server/checker
    environment:
      CGO_ENABLED: 0
    when:
      branch:
        exclude:
          - master

  - name: build evdist
    image: golang:alpine
    commands:
      - go build -buildvcs=false -o deploy/evdist-${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH} srs.epita.fr/fic-server/evdist
    environment:
      CGO_ENABLED: 0
    when:
      branch:
        exclude:
          - master

  - name: build generator
    image: golang:alpine
    commands:
      - go build -buildvcs=false -o deploy/generator-${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH} srs.epita.fr/fic-server/generator
    environment:
      CGO_ENABLED: 0
    when:
      branch:
        exclude:
          - master

  - name: build receiver
    image: golang:alpine
    commands:
      - go build -buildvcs=false -o deploy/receiver-${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH} srs.epita.fr/fic-server/receiver
    environment:
      CGO_ENABLED: 0
    when:
      branch:
        exclude:
          - master

  - name: build frontend fic ui
    image: node:22-alpine
    commands:
      - cd frontend/fic
      - npm install --network-timeout=100000
      - npm run build
      - tar chjf ../../deploy/htdocs-frontend-fic.tar.bz2 build
    when:
      branch:
        exclude:
          - master

  - name: build dashboard
    image: golang:alpine
    commands:
      - go build -buildvcs=false -o deploy/dashboard-${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH} srs.epita.fr/fic-server/dashboard
      - tar chjf deploy/htdocs-dashboard.tar.bz2 htdocs-dashboard
    environment:
      CGO_ENABLED: 0
    when:
      branch:
        exclude:
          - master

  - name: build repochecker
    image: golang:alpine
    commands:
      - apk --no-cache add build-base
      - go build -buildvcs=false --tags checkupdate -o deploy/repochecker-${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH} srs.epita.fr/fic-server/repochecker
      - go build -buildvcs=false -buildmode=plugin -o deploy/repochecker-epita-rules-${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}.so srs.epita.fr/fic-server/repochecker/epita
      - go build -buildvcs=false -buildmode=plugin -o deploy/repochecker-file-inspector-rules-${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}.so srs.epita.fr/fic-server/repochecker/file-inspector
      - go build -buildvcs=false -buildmode=plugin -o deploy/repochecker-grammalecte-rules-${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}.so srs.epita.fr/fic-server/repochecker/grammalecte
      - go build -buildvcs=false -buildmode=plugin -o deploy/repochecker-pcap-inspector-rules-${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}.so srs.epita.fr/fic-server/repochecker/pcap-inspector
      - go build -buildvcs=false -buildmode=plugin -o deploy/repochecker-videos-rules-${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}.so srs.epita.fr/fic-server/repochecker/videos
      - grep "const version" repochecker/update.go | sed -r 's/^.*=\s*(\S.*)$/\1/' > deploy/repochecker.version
    when:
      branch:
        exclude:
          - master

  - name: build qa
    image: golang:alpine
    commands:
      - go build -buildvcs=false -o deploy/qa-${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH} srs.epita.fr/fic-server/qa
    environment:
      CGO_ENABLED: 0
    when:
      branch:
        exclude:
          - master

  - name: docker admin
    image: plugins/docker
    settings:
      username:
        from_secret: docker_username
      password:
        from_secret: docker_password
      repo: nemunaire/fic-admin
      auto_tag: true
      auto_tag_suffix: ${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}
      dockerfile: Dockerfile-admin
    when:
      branch:
        - master

  - name: docker checker
    image: plugins/docker
    settings:
      username:
        from_secret: docker_username
      password:
        from_secret: docker_password
      repo: nemunaire/fic-checker
      auto_tag: true
      auto_tag_suffix: ${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}
      dockerfile: Dockerfile-checker
    when:
      branch:
        - master

  - name: docker evdist
    image: plugins/docker
    settings:
      username:
        from_secret: docker_username
      password:
        from_secret: docker_password
      repo: nemunaire/fic-evdist
      auto_tag: true
      auto_tag_suffix: ${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}
      dockerfile: Dockerfile-evdist
    when:
      branch:
        - master

  - name: docker generator
    image: plugins/docker
    settings:
      username:
        from_secret: docker_username
      password:
        from_secret: docker_password
      repo: nemunaire/fic-generator
      auto_tag: true
      auto_tag_suffix: ${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}
      dockerfile: Dockerfile-generator
    when:
      branch:
        - master

  - name: docker receiver
    image: plugins/docker
    settings:
      username:
        from_secret: docker_username
      password:
        from_secret: docker_password
      repo: nemunaire/fic-receiver
      auto_tag: true
      auto_tag_suffix: ${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}
      dockerfile: Dockerfile-receiver
    when:
      branch:
        - master

  - name: docker frontend nginx
    image: plugins/docker
    settings:
      username:
        from_secret: docker_username
      password:
        from_secret: docker_password
      repo: nemunaire/fic-nginx
      auto_tag: true
      auto_tag_suffix: ${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}
      dockerfile: Dockerfile-nginx
    when:
      branch:
        - master

  - name: docker frontend ui
    image: plugins/docker
    settings:
      username:
        from_secret: docker_username
      password:
        from_secret: docker_password
      repo: nemunaire/fic-frontend-ui
      auto_tag: true
      auto_tag_suffix: ${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}
      dockerfile: Dockerfile-frontend-ui
    when:
      branch:
        - master

  - name: docker dashboard
    image: plugins/docker
    settings:
      username:
        from_secret: docker_username
      password:
        from_secret: docker_password
      repo: nemunaire/fic-dashboard
      auto_tag: true
      auto_tag_suffix: ${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}
      dockerfile: Dockerfile-dashboard
    when:
      branch:
        - master

  - name: docker qa
    image: plugins/docker
    settings:
      username:
        from_secret: docker_username
      password:
        from_secret: docker_password
      repo: nemunaire/fic-qa
      auto_tag: true
      auto_tag_suffix: ${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}
      dockerfile: Dockerfile-qa
    when:
      branch:
        - master

  - name: docker repochecker
    image: plugins/docker
    settings:
      username:
        from_secret: docker_username
      password:
        from_secret: docker_password
      repo: nemunaire/fic-repochecker
      auto_tag: true
      auto_tag_suffix: ${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}
      dockerfile: Dockerfile-repochecker
    when:
      branch:
        - master

  - name: docker remote-scores-sync-zqds
    image: plugins/docker
    settings:
      username:
        from_secret: docker_username
      password:
        from_secret: docker_password
      repo: nemunaire/fic-remote-scores-sync-zqds
      auto_tag: true
      auto_tag_suffix: ${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}
      dockerfile: Dockerfile-remote-scores-sync-zqds
    when:
      branch:
        - master

  - name: docker remote-challenge-sync-airbus
    image: plugins/docker
    settings:
      username:
        from_secret: docker_username
      password:
        from_secret: docker_password
      repo: nemunaire/fic-remote-challenge-sync-airbus
      auto_tag: true
      auto_tag_suffix: ${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}
      dockerfile: Dockerfile-remote-challenge-sync-airbus
    when:
      branch:
        - master

  - name: docker fic-get-remote-files
    failure: ignore
    image: plugins/docker
    settings:
      username:
        from_secret: docker_username
      password:
        from_secret: docker_password
      repo: nemunaire/fic-get-remote-files
      auto_tag: true
      auto_tag_suffix: ${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}
      dockerfile: Dockerfile-get-remote-files
    when:
      branch:
        - master

  - name: docker fickit-deploy
    image: plugins/docker
    settings:
      username:
        from_secret: docker_username
      password:
        from_secret: docker_password
      repo: nemunaire/fickit-deploy
      auto_tag: true
      auto_tag_suffix: ${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}
      dockerfile: Dockerfile-deploy
    when:
      branch:
        - master

trigger:
  event:
  - cron
  - push
  - tag

---
kind: pipeline
type: docker
name: build-arm64

platform:
  os: linux
  arch: arm64

workspace:
  base: /go
  path: src/srs.epita.fr/fic-server

steps:
  - name: get deps
    image: golang:alpine
    commands:
      - apk --no-cache add git
      - go get -d ./...
      - mkdir deploy

  - name: build admin
    image: golang:alpine
    commands:
      - apk --no-cache add build-base
      - go build -buildvcs=false -o deploy/admin-${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH} srs.epita.fr/fic-server/admin
    environment:
      CGO_ENABLED: 0
    when:
      branch:
        exclude:
          - master

  - name: build checker
    image: golang:alpine
    commands:
      - go build -buildvcs=false -o deploy/checker-${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH} srs.epita.fr/fic-server/checker
    environment:
      CGO_ENABLED: 0
    when:
      branch:
        exclude:
          - master

  - name: build evdist
    image: golang:alpine
    commands:
      - go build -buildvcs=false -o deploy/evdist-${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH} srs.epita.fr/fic-server/evdist
    environment:
      CGO_ENABLED: 0
    when:
      branch:
        exclude:
          - master

  - name: build generator
    image: golang:alpine
    commands:
      - go build -buildvcs=false -o deploy/generator-${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH} srs.epita.fr/fic-server/generator
    environment:
      CGO_ENABLED: 0
    when:
      branch:
        exclude:
          - master

  - name: build receiver
    image: golang:alpine
    commands:
      - go build -buildvcs=false -o deploy/receiver-${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH} srs.epita.fr/fic-server/receiver
    environment:
      CGO_ENABLED: 0
    when:
      branch:
        exclude:
          - master

  - name: build frontend fic ui
    image: node:22-alpine
    commands:
      - cd frontend/fic
      - npm install --network-timeout=100000
      - npm run build
    when:
      branch:
        exclude:
          - master

  - name: build dashboard
    image: golang:alpine
    commands:
      - go build -buildvcs=false -o deploy/dashboard-${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH} srs.epita.fr/fic-server/dashboard
    environment:
      CGO_ENABLED: 0
    when:
      branch:
        exclude:
          - master

  - name: build repochecker
    image: golang:alpine
    commands:
      - apk --no-cache add build-base
      - go build -buildvcs=false --tags checkupdate -o deploy/repochecker-${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH} srs.epita.fr/fic-server/repochecker
    environment:
      CGO_ENABLED: 0
    when:
      branch:
        exclude:
          - master

  - name: build repochecker for macOS
    image: golang:alpine
    commands:
      - apk --no-cache add build-base
      - go build -buildvcs=false --tags checkupdate -o deploy/repochecker-darwin-${DRONE_STAGE_ARCH} srs.epita.fr/fic-server/repochecker
    environment:
      CGO_ENABLED: 0
      GOOS: darwin
      GOARCH: arm64
    when:
      branch:
        exclude:
          - master

  - name: build qa ui
    image: node:22-alpine
    commands:
      - cd qa/ui
      - npm install --network-timeout=100000
      - npm run build
      - tar chjf ../../deploy/htdocs-qa.tar.bz2 build
    when:
      branch:
        exclude:
          - master

  - name: build qa
    image: golang:alpine
    commands:
      - go build -buildvcs=false -o deploy/qa-${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH} srs.epita.fr/fic-server/qa
    environment:
      CGO_ENABLED: 0
    when:
      branch:
        exclude:
          - master

  - name: docker admin
    image: plugins/docker
    settings:
      username:
        from_secret: docker_username
      password:
        from_secret: docker_password
      repo: nemunaire/fic-admin
      auto_tag: true
      auto_tag_suffix: ${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}
      dockerfile: Dockerfile-admin
    when:
      branch:
        - master

  - name: docker checker
    image: plugins/docker
    settings:
      username:
        from_secret: docker_username
      password:
        from_secret: docker_password
      repo: nemunaire/fic-checker
      auto_tag: true
      auto_tag_suffix: ${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}
      dockerfile: Dockerfile-checker
    when:
      branch:
        - master

  - name: docker evdist
    image: plugins/docker
    settings:
      username:
        from_secret: docker_username
      password:
        from_secret: docker_password
      repo: nemunaire/fic-evdist
      auto_tag: true
      auto_tag_suffix: ${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}
      dockerfile: Dockerfile-evdist
    when:
      branch:
        - master

  - name: docker generator
    image: plugins/docker
    settings:
      username:
        from_secret: docker_username
      password:
        from_secret: docker_password
      repo: nemunaire/fic-generator
      auto_tag: true
      auto_tag_suffix: ${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}
      dockerfile: Dockerfile-generator
    when:
      branch:
        - master

  - name: docker fic-get-remote-files
    failure: ignore
    image: plugins/docker
    settings:
      username:
        from_secret: docker_username
      password:
        from_secret: docker_password
      repo: nemunaire/fic-get-remote-files
      auto_tag: true
      auto_tag_suffix: ${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}
      dockerfile: Dockerfile-get-remote-files
    when:
      branch:
        - master

  - name: docker receiver
    image: plugins/docker
    settings:
      username:
        from_secret: docker_username
      password:
        from_secret: docker_password
      repo: nemunaire/fic-receiver
      auto_tag: true
      auto_tag_suffix: ${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}
      dockerfile: Dockerfile-receiver
    when:
      branch:
        - master

  - name: docker frontend nginx
    image: plugins/docker
    settings:
      username:
        from_secret: docker_username
      password:
        from_secret: docker_password
      repo: nemunaire/fic-nginx
      auto_tag: true
      auto_tag_suffix: ${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}
      dockerfile: Dockerfile-nginx
    when:
      branch:
        - master

  - name: docker dashboard
    image: plugins/docker
    settings:
      username:
        from_secret: docker_username
      password:
        from_secret: docker_password
      repo: nemunaire/fic-dashboard
      auto_tag: true
      auto_tag_suffix: ${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}
      dockerfile: Dockerfile-dashboard
    when:
      branch:
        - master

  - name: docker qa
    image: plugins/docker
    settings:
      username:
        from_secret: docker_username
      password:
        from_secret: docker_password
      repo: nemunaire/fic-qa
      auto_tag: true
      auto_tag_suffix: ${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}
      dockerfile: Dockerfile-qa
    when:
      branch:
        - master

  - name: docker repochecker
    image: plugins/docker
    settings:
      username:
        from_secret: docker_username
      password:
        from_secret: docker_password
      repo: nemunaire/fic-repochecker
      auto_tag: true
      auto_tag_suffix: ${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}
      dockerfile: Dockerfile-repochecker
    when:
      branch:
        - master

trigger:
  event:
  - cron
  - push
  - tag

---
kind: pipeline
name: docker-manifest
steps:
  - name: publish admin
    image: plugins/manifest
    settings:
      auto_tag: true
      ignore_missing: true
      spec: .drone-manifest-fic-admin.yml
      username:
        from_secret: docker_username
      password:
        from_secret: docker_password

  - name: publish checker
    image: plugins/manifest
    settings:
      auto_tag: true
      ignore_missing: true
      spec: .drone-manifest-fic-checker.yml
      username:
        from_secret: docker_username
      password:
        from_secret: docker_password

  - name: publish evdist
    image: plugins/manifest
    settings:
      auto_tag: true
      ignore_missing: true
      spec: .drone-manifest-fic-evdist.yml
      username:
        from_secret: docker_username
      password:
        from_secret: docker_password

  - name: publish generator
    image: plugins/manifest
    settings:
      auto_tag: true
      ignore_missing: true
      spec: .drone-manifest-fic-generator.yml
      username:
        from_secret: docker_username
      password:
        from_secret: docker_password

  - name: publish receiver
    image: plugins/manifest
    settings:
      auto_tag: true
      ignore_missing: true
      spec: .drone-manifest-fic-receiver.yml
      username:
        from_secret: docker_username
      password:
        from_secret: docker_password

  - name: publish frontend nginx
    image: plugins/manifest
    settings:
      auto_tag: true
      ignore_missing: true
      spec: .drone-manifest-fic-nginx.yml
      username:
        from_secret: docker_username
      password:
        from_secret: docker_password

  - name: publish frontend ui
    image: plugins/manifest
    settings:
      auto_tag: true
      ignore_missing: true
      spec: .drone-manifest-fic-frontend-ui.yml
      username:
        from_secret: docker_username
      password:
        from_secret: docker_password

  - name: publish dashboard
    image: plugins/manifest
    settings:
      auto_tag: true
      ignore_missing: true
      spec: .drone-manifest-fic-dashboard.yml
      username:
        from_secret: docker_username
      password:
        from_secret: docker_password

  - name: publish repochecker
    image: plugins/manifest
    settings:
      auto_tag: true
      ignore_missing: true
      spec: .drone-manifest-fic-repochecker.yml
      username:
        from_secret: docker_username
      password:
        from_secret: docker_password

  - name: publish qa
    image: plugins/manifest
    settings:
      auto_tag: true
      ignore_missing: true
      spec: .drone-manifest-fic-qa.yml
      username:
        from_secret: docker_username
      password:
        from_secret: docker_password

  - name: docker fic-get-remote-files
    failure: ignore
    image: plugins/docker
    settings:
      username:
        from_secret: docker_username
      password:
        from_secret: docker_password
      repo: nemunaire/fic-get-remote-files
      auto_tag: true
      auto_tag_suffix: ${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}
      dockerfile: Dockerfile-get-remote-files
    when:
      branch:
        - master

  - name: publish fickit-deploy
    image: plugins/manifest
    settings:
      auto_tag: true
      ignore_missing: true
      spec: .drone-manifest-fickit-deploy.yml
      username:
        from_secret: docker_username
      password:
        from_secret: docker_password

trigger:
  event:
  - push
  - tag

depends_on:
- build-amd64
- build-arm64
