summaryrefslogtreecommitdiffstats
path: root/.github/workflows/tests.yml
blob: bb20eaefe3bca7f4ab95c45103b0d3d25b4eb020 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
name: Tests

on:
  push:

jobs:
  tests:
    name: test ${{matrix.db}} ruby-${{ matrix.ruby }}
    runs-on: ubuntu-latest

    strategy:
      matrix:
        ruby: ['3.1', '3.2', '3.3']
        db: ['postgresql', 'mysql2']
      fail-fast: false

    services:
      postgres:
        image: postgres:13
        env:
          POSTGRES_DB: redmine_test
          POSTGRES_USER: root
          POSTGRES_PASSWORD: root
        ports:
          - 5432:5432
        options: >-
          --health-cmd pg_isready
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5

      mysql:
        image: mysql:8.0
        env:
          MYSQL_DATABASE: redmine_test
          MYSQL_ROOT_PASSWORD: 'root'
        ports:
          - 3306:3306
        options: >-
          --health-cmd="mysqladmin ping"
          --health-interval=10s
          --health-timeout=5s
          --health-retries=3

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Install dependencies and configure environment
        run: |
          sudo apt-get update
          sudo apt-get install --yes --quiet ghostscript gsfonts locales bzr cvs
          sudo locale-gen en_US # for bazaar non ascii test

      - name: Allow imagemagick to read PDF files
        run: |
          echo '<policymap>' > policy.xml
          echo '<policy domain="coder" rights="read | write" pattern="PDF" />' >> policy.xml
          echo '</policymap>' >> policy.xml
          sudo rm /etc/ImageMagick-6/policy.xml
          sudo mv policy.xml /etc/ImageMagick-6/policy.xml

      - name: Prepare Redmine database configuration
        run: |
          cat > config/database.yml <<EOF
          test:
            adapter: ${{ matrix.db }}
            database: redmine_test
            username: root
            password: root
            host: 127.0.0.1
          EOF

      - name: Install Ruby and gems
        uses: ruby/setup-ruby@v1.176.0
        with:
          ruby-version: ${{ matrix.ruby }}
          bundler-cache: true

      - name: Run prepare test environment
        env:
          RAILS_ENV: test
          SCMS: subversion,git,git_utf8,filesystem,bazaar,cvs
        run: |
          bundle exec rake ci:about
          bundle exec rake ci:setup
          bundle exec rake db:environment:set

      - name: Run tests
        run: |
          bin/rails test
          bin/rails test:autoload

      - name: Run bazaar non ascii test
        env:
          LANG: en_US.ISO8859-1
          LC_ALL: en_US.ISO8859-1
        run: |
          bin/rails test test/unit/repository_bazaar_test.rb

      - name: Run autoload test
        run: |
          bin/rails test:autoload