- hosts: test_systems
  name: Seed test system with data
  become: yes
  tasks:
    - name: Checkout WikibaseImport
      git:
        repo: "https://github.com/wikidata/WikibaseImport"
        dest: "{{ MW_PATH }}/extensions/WikibaseImport"
        depth: 1
        version: master
    - name: Run Composer install
      command:
        chdir: "{{ PROJECT_DIR }}"
        cmd: docker run --rm --volume {{ MW_PATH }}:/app composer install
    - name: Ensure config is in place
      copy:
        src: files/LocalSettings.d/wikibaseImport.php
        dest: "{{ MW_PATH }}/LocalSettings.d/wikibaseImport.php"
        mode: 0644
    - name: Ensure importIds.txt is in place
      copy:
        src: files/importIds.txt
        dest: "{{ MW_PATH }}/extensions/WikibaseImport/data/importIds.txt"
        mode: 0644
    - name: Run MediaWiki update script to create WikibaseImport tables
      command:
        chdir: "{{ PROJECT_DIR }}"
        cmd: docker-compose exec -T wikibase php maintenance/update.php
    - name: Run import script in wikibase webserver docker container
      command:
        chdir: "{{ PROJECT_DIR }}"
        cmd: docker-compose exec -T wikibase php extensions/WikibaseImport/maintenance/importEntities.php --file /var/www/html/extensions/WikibaseImport/data/importIds.txt
    - name: Ensure config building script is in place
      copy:
        src: files/makeManifestEntityConfig.php
        dest: "{{ MW_PATH }}/makeManifestEntityConfig.php"
        mode: 0644
    - name: make equivalent entity config
      command:
        chdir: "{{ PROJECT_DIR }}"
        cmd: docker-compose exec -T wikibase php makeManifestEntityConfig.php
